From 7d31b3eea8d846651ffaf5ec8597c6f5cf2ad526 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Thu, 12 Nov 2026 06:42:40 -0600 Subject: [PATCH] Present: Copy link for the setup's current choices - addressFor builds the playing address from the choices, for Play and the new Copy link at the bottom of the setup Co-Authored-By: Claude Opus 5.5 --- src/pages/EventPresent.tsx | 69 ++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/src/pages/EventPresent.tsx b/src/pages/EventPresent.tsx index 20ceb56..51c194c 100644 --- a/src/pages/EventPresent.tsx +++ b/src/pages/EventPresent.tsx @@ -84,7 +84,7 @@ screen (the browser's), S goes back to the setup. ═══════════════════════════════════════════════════════════════ */ -import { ArrowDown, ArrowUp, ArrowsOut, CaretLeft, CaretRight, DotsSixVertical, Gear, Pause, Play } from '@phosphor-icons/react' +import { ArrowDown, ArrowUp, ArrowsOut, CaretLeft, CaretRight, Check, DotsSixVertical, Gear, LinkSimple, Pause, Play } from '@phosphor-icons/react' import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from 'react' import { useParams, useSearchParams } from 'react-router-dom' @@ -577,25 +577,31 @@ export default function EventPresent() { onPlay={(next) => { // Full screen needs the click itself, so it's asked for here. document.documentElement.requestFullscreen?.().catch(() => {}) - const out = new URLSearchParams() - if (next.skipped.size) out.set('skip', [...next.skipped].sort((a, b) => a - b).join(',')) - if (next.hidden.size) out.set('hide', [...next.hidden].join(',')) - for (const kind of KINDS) out.set(kind.key, String(next.seconds[kind.key])) - out.set('screen', String(next.screen)) - // Not 'tag': that's the tag slides' seconds. - if (next.only) out.set('only', next.only) - if (next.order?.length) out.set('order', next.order.join(',')) - if (next.theme) out.set('theme', next.theme) - if (next.lists.size) out.set('lists', [...next.lists].join(',')) - if (next.titles.size) out.set('titles', [...next.titles].join(',')) - if (next.pictures.size) out.set('pictures', [...next.pictures].map(([at, side]) => `${at}:${side}`).join(',')) - out.set('play', '1') - setParams(out) + setParams(addressFor(next)) }} /> ) } +/* The setup's choices as the address's query, playing (`play=1`): + what Play goes to and Copy link copies. readSettings reads it. */ +function addressFor(next: Settings): URLSearchParams { + const out = new URLSearchParams() + if (next.skipped.size) out.set('skip', [...next.skipped].sort((a, b) => a - b).join(',')) + if (next.hidden.size) out.set('hide', [...next.hidden].join(',')) + for (const kind of KINDS) out.set(kind.key, String(next.seconds[kind.key])) + out.set('screen', String(next.screen)) + // Not 'tag': that's the tag slides' seconds. + if (next.only) out.set('only', next.only) + if (next.order?.length) out.set('order', next.order.join(',')) + if (next.theme) out.set('theme', next.theme) + if (next.lists.size) out.set('lists', [...next.lists].join(',')) + if (next.titles.size) out.set('titles', [...next.titles].join(',')) + if (next.pictures.size) out.set('pictures', [...next.pictures].map(([at, side]) => `${at}:${side}`).join(',')) + out.set('play', '1') + return out +} + /* ── Setup ──────────────────────────────────────────────────── */ function Setup({ @@ -626,6 +632,17 @@ function Setup({ const [titles, setTitles] = useState(settings.titles) const [pictures, setPictures] = useState(settings.pictures) const [dragging, setDragging] = useState(null) + const [copied, setCopied] = useState<'yes' | 'failed' | null>(null) + const picked: Settings = { skipped, hidden, seconds, screen, only, order, theme, lists, titles, pictures } + // The address that starts a screen with these choices, playing. + const copyLink = () => { + const link = `${window.location.origin}${window.location.pathname}?${addressFor(picked)}` + navigator.clipboard + .writeText(link) + .then(() => setCopied('yes')) + .catch(() => setCopied('failed')) + window.setTimeout(() => setCopied(null), 2500) + } const slides = ordered(buildSlides(sections, schedules, { skipped, hidden, seconds, only, lists, titles, pictures }), order) const count = slides.length // Moves a slide in the list, which then names every slide shown. @@ -655,8 +672,8 @@ function Setup({ {title}

- Pick what to show and for how long, then Play. It loops until you stop it. Bookmark the address after - pressing Play to start a screen the same way next time. + Pick what to show and for how long, then Play. It loops until you stop it. Copy link (at the bottom) gives + an address that starts a screen with these choices, playing, eg. to bookmark on a signage device.

@@ -1046,7 +1063,7 @@ function Setup({ + + {copied === 'failed' ? "Couldn't copy: press Play, then copy the address bar." : ''} + Back to the event