fix: one status tile list for both admin cards; clear the copied timer on unmount

- The mail import's status tiles (which, labels, tones) were written out
  in the desktop and the mobile card alike; statTiles in the shared model
  holds them, each card keeps its own look.
- The journey share link set 'copied' back two seconds after a copy even
  when the dialog had closed, which also broke a client test run (window
  gone at teardown). useCopied, the trip share's hook, moves to hooks/ and
  serves both; it clears its timer on unmount.
- PlanLlmConfig is not exported: only the union is used outside.
This commit is contained in:
Maurice
2026-11-13 21:16:17 +01:00
parent 6ac7bd2d96
commit dfbe23e5b8
9 changed files with 134 additions and 50 deletions
+1 -15
View File
@@ -7,7 +7,7 @@ import { useCanDo } from '../../store/permissionsStore'
import { useTripStore } from '../../store/tripStore'
import { useTranslation } from '../../i18n'
import { getApiErrorMessage } from '../../types'
import { copyText } from '../../utils/clipboard'
import { useCopied } from '../../hooks/useCopied'
import { refusedOffline } from '../../utils/needsConnection'
// The state behind the share dialog, shared by the desktop dialog and the one the
@@ -37,20 +37,6 @@ export const SHARE_OPTIONS: { key: SharePerm; label: string }[] = [
{ key: 'share_hide_images', label: 'share.optHideImages' },
]
/** Copy text and show "Copied" for two seconds, the timer restarting on every copy. */
function useCopied() {
const [copied, setCopied] = useState(false)
const timer = useRef<ReturnType<typeof setTimeout> | null>(null)
useEffect(() => () => { if (timer.current) clearTimeout(timer.current) }, [])
const copy = async (text: string | null) => {
if (!text || !(await copyText(text))) return
setCopied(true)
if (timer.current) clearTimeout(timer.current)
timer.current = setTimeout(() => setCopied(false), 2000)
}
return { copied, copy }
}
/** The public read-only link and what it may show. */
export function useShareLink(tripId: number) {
const [token, setToken] = useState<string | null>(null)