diff --git a/client/scripts/eslint-baseline.json b/client/scripts/eslint-baseline.json index 41d1c3937..2c0a692c6 100644 --- a/client/scripts/eslint-baseline.json +++ b/client/scripts/eslint-baseline.json @@ -4,7 +4,7 @@ "@typescript-eslint/no-misused-promises": 810, "no-console": 85, "complexity": 214, - "@typescript-eslint/no-explicit-any": 114, + "@typescript-eslint/no-explicit-any": 113, "trek/no-swallowed-catch": 124, "max-params": 31, "trek/store-without-selector": 65, diff --git a/client/src/api/journeyRecordings.test.ts b/client/src/api/journeyRecordings.test.ts index 83ec0e8b7..c751a57a8 100644 --- a/client/src/api/journeyRecordings.test.ts +++ b/client/src/api/journeyRecordings.test.ts @@ -84,17 +84,11 @@ describe('journeyRecordingsApi', () => { }); it('FE-API-JOURNEY-RECORDINGS-004: sends a GPX file with its fields and drops the day of one source (#3085)', async () => { - const sent: Array<{ file: string | null; date: unknown; utcOffsetMinutes: unknown }> = []; + const sent: Array<{ contentType: string | null; body: string }> = []; const deleted: string[] = []; server.use( http.post(`${BASE}/import-gpx`, async ({ request }) => { - const form = await request.formData(); - const file = form.get('file'); - sent.push({ - file: file instanceof Blob ? await file.text() : null, - date: form.get('date'), - utcOffsetMinutes: form.get('utcOffsetMinutes'), - }); + sent.push({ contentType: request.headers.get('content-type'), body: await request.text() }); return HttpResponse.json({ days: [], untimedPoints: 0 }); }), http.delete(`${BASE}/2026-05-14`, ({ request }) => { @@ -112,10 +106,15 @@ describe('journeyRecordingsApi', () => { await journeyRecordingsApi.remove(7, '2026-05-14', 'gpx'); await journeyRecordingsApi.remove(7, '2026-05-14'); - expect(sent).toEqual([ - { file: '', date: '2026-05-14', utcOffsetMinutes: '-300' }, - { file: '', date: null, utcOffsetMinutes: null }, - ]); + expect(sent).toHaveLength(2); + for (const part of sent) { + expect(part.contentType).toMatch(/^multipart\/form-data;\s*boundary=/i); + expect(part.body).toContain('name="file"'); + expect(part.body).toContain(''); + } + expect(sent[0]?.body).toMatch(/name="date"\s+2026-05-14/); + expect(sent[0]?.body).toMatch(/name="utcOffsetMinutes"\s+-300/); + expect(sent[1]?.body).not.toMatch(/name="(?:date|utcOffsetMinutes)"/); expect(deleted).toEqual(['?source=gpx', '']); }); }); diff --git a/client/src/components/Assistant/cards/journey/JourneyEntriesCard.test.tsx b/client/src/components/Assistant/cards/journey/JourneyEntriesCard.test.tsx index 73054b59b..c143416ad 100644 --- a/client/src/components/Assistant/cards/journey/JourneyEntriesCard.test.tsx +++ b/client/src/components/Assistant/cards/journey/JourneyEntriesCard.test.tsx @@ -98,7 +98,7 @@ describe('the journal entries card', () => { expect(screen.getByText('4 photos')).toBeInTheDocument(); expect(screen.getByText('Opens with a video')).toBeInTheDocument(); expect(screen.getByText('Berlin 2026')).toBeInTheDocument(); - expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/7/preview'); + expect(container.querySelector('img')).toHaveAttribute('src', '/api/photos/7/thumbnail'); }); it('FE-AI-JOURNEY-002: an entry without a photo takes the width, and a known mood and weather are named', () => { @@ -236,7 +236,7 @@ describe('a change row of a journal entry', () => { expect(screen.getByText('Tue, Oct 21')).toBeInTheDocument(); expect(screen.getByText('Museum Island')).toBeInTheDocument(); expect(screen.queryByText('Not a fact')).toBeNull(); - expect(document.querySelector('img')).toHaveAttribute('src', '/api/photos/7/preview'); + expect(document.querySelector('img')).toHaveAttribute('src', '/api/photos/7/thumbnail'); first.unmount(); const second = inView(, { onOpen }); diff --git a/client/src/components/Journey/JourneyDayRecordingButton.tsx b/client/src/components/Journey/JourneyDayRecordingButton.tsx index 792642e7a..f4da72a94 100644 --- a/client/src/components/Journey/JourneyDayRecordingButton.tsx +++ b/client/src/components/Journey/JourneyDayRecordingButton.tsx @@ -108,66 +108,21 @@ export default function JourneyDayRecordingButton({ } if (gpx?.day) { - const { distance, label } = keptLabel(gpx.day); - const full = `${label} ${t('journey.recording.gpx.source')}`; return ( - <> - {fileInput} - - - - - + ); } if (!canTakeOver && !needsConnection && !canImportGpx) return null; - // Only a file to read: the button opens the file picker straight away. if (canImportGpx && !canTakeOver) { - const label = t('journey.recording.gpx.import'); - return ( - <> - {fileInput} - - - - - ); + return ; } const label = canTakeOver ? t('journey.recording.takeOver') : t('dawarich.error.offline'); @@ -190,11 +145,9 @@ export default function JourneyDayRecordingButton({ true ) : onOpen - : canImportGpx - ? pickFile - : undefined + : undefined } - aria-disabled={!canTakeOver && !canImportGpx} + aria-disabled={!canTakeOver} aria-label={label} aria-haspopup={canTakeOver && canImportGpx ? 'menu' : undefined} data-testid="journey-day-recording" @@ -208,3 +161,87 @@ export default function JourneyDayRecordingButton({ ); } + +function ImportGpxButton({ + busy, + fileInput, + pickFile, +}: { + busy: boolean; + fileInput: React.ReactNode; + pickFile: () => void; +}) { + const { t } = useTranslation(); + const label = t('journey.recording.gpx.import'); + return ( + <> + {fileInput} + + + + + ); +} + +function GpxRecordingPill({ + gpx, + detail, + canImport, + fileInput, + pickFile, +}: { + gpx: DayGpx; + detail: { distance: string; label: string }; + canImport: boolean; + fileInput: React.ReactNode; + pickFile: () => void; +}) { + const { t } = useTranslation(); + const menu = useContextMenu(); + const { distance, label } = detail; + const actionable = canImport && !gpx.busy; + const full = `${label} ${t('journey.recording.gpx.source')}`; + return ( + <> + {fileInput} + + + + + + ); +} diff --git a/client/src/components/Journey/JourneyDetailPageEntryCard.tsx b/client/src/components/Journey/JourneyDetailPageEntryCard.tsx index eda476015..2d11109a6 100644 --- a/client/src/components/Journey/JourneyDetailPageEntryCard.tsx +++ b/client/src/components/Journey/JourneyDetailPageEntryCard.tsx @@ -181,7 +181,7 @@ export function EntryCard({ entry, readOnly, onEdit, onDelete, onPhotoClick, com )} - {comments &&
{comments}
} + {comments &&
{comments}
} ) diff --git a/client/src/components/Journey/JourneyEntryComments.tsx b/client/src/components/Journey/JourneyEntryComments.tsx index ae608e1c5..d04483f80 100644 --- a/client/src/components/Journey/JourneyEntryComments.tsx +++ b/client/src/components/Journey/JourneyEntryComments.tsx @@ -8,10 +8,10 @@ import { Tooltip } from '../shared/Tooltip'; /** One comment as the thread draws it: in the app and on the shared page alike. */ export interface EntryCommentItem { id: number; - author_name: string | null; + author_name?: string | null; is_guest: boolean; body: string; - created_at: string | null; + created_at?: string | null; hidden?: boolean; own?: boolean; } @@ -99,7 +99,7 @@ export default function JourneyEntryComments({ setBody(''); }; - const dateOf = (iso: string | null) => + const dateOf = (iso: string | null | undefined) => iso ? new Date(iso).toLocaleDateString(locale || undefined, { day: 'numeric', month: 'short' }) : ''; const toggle = ( @@ -158,7 +158,7 @@ export default function JourneyEntryComments({ + + ) +} + /** What readers of the link may do besides reading (#1702, #1669): each off until switched on. */ function ShareReaders({ link, access, onToggle }: { link: JourneyShareLink; access: ShareAccess; onToggle: (key: JourneyShareInteraction) => void }) { const { t } = useTranslation() @@ -66,24 +96,15 @@ function ShareReaders({ link, access, onToggle }: { link: JourneyShareLink; acce const blocked = key === 'allow_comments' && !link.share_timeline const on = !blocked && !!link[key] return ( - - - + onToggle(key)} + /> ) })} {link.allow_subscriptions && } @@ -149,24 +170,15 @@ function ShareMapExtras({ link, onToggle }: { link: JourneyShareLink; onToggle: const Icon = EXTRA_ICONS[key] const on = mapShared && !!link[key] return ( - - - + onToggle(key)} + /> ) })} diff --git a/client/src/components/Journey/MobileEntryView.tsx b/client/src/components/Journey/MobileEntryView.tsx index 4ca29e709..92ab5a0b9 100644 --- a/client/src/components/Journey/MobileEntryView.tsx +++ b/client/src/components/Journey/MobileEntryView.tsx @@ -295,7 +295,7 @@ export default function MobileEntryView({ entry, readOnly, publicPhotoUrl, onClo )} - {comments &&
{comments}
} + {comments &&
{comments}
} diff --git a/client/src/components/Journey/journeyRecordingModel.test.ts b/client/src/components/Journey/journeyRecordingModel.test.ts index c1c013edb..35b0f013b 100644 --- a/client/src/components/Journey/journeyRecordingModel.test.ts +++ b/client/src/components/Journey/journeyRecordingModel.test.ts @@ -105,6 +105,6 @@ describe('journeyRecordingModel', () => { expect(gpxImportErrorText(httpError('gpx_no_times'), t)).toBe('t:journey.recording.gpx.error.noTimes'); expect(gpxImportErrorText(httpError('recording_empty'), t)).toBe('t:journey.recording.gpx.error.emptyDay'); expect(gpxImportErrorText(httpError('gpx_too_many_days'), t)).toBe('t:journey.recording.gpx.error.tooManyDays'); - expect(gpxImportErrorText(new Error('boom'), t)).toBe('t:common.errorTitle'); + expect(gpxImportErrorText(new Error('boom'), t)).toBe('t:journey.recording.gpx.failed'); }); }); diff --git a/client/src/components/Journey/useJourneyComments.ts b/client/src/components/Journey/useJourneyComments.ts index 0789f3e3d..e304b6655 100644 --- a/client/src/components/Journey/useJourneyComments.ts +++ b/client/src/components/Journey/useJourneyComments.ts @@ -1,15 +1,8 @@ import type { JourneyComment } from '@trek/shared'; -import { useCallback, useEffect, useMemo, useState } from 'react'; +import { useCallback, useMemo } from 'react'; import { journeySocialRepo } from '../../repo/journeySocialRepo'; -import { useServerPing } from '../../sync/useServerPing'; +import { useJourneyLiveData } from './useJourneyLiveData'; -interface Loaded { - journeyId: number | null; - comments: JourneyComment[]; - canModerate: boolean; -} - -const NOTHING: Loaded = { journeyId: null, comments: [], canModerate: false }; const NO_COMMENTS: JourneyComment[] = []; interface JourneyCommentsState { @@ -36,41 +29,8 @@ interface JourneyCommentsState { * can say so. */ export function useJourneyComments(journeyId: number | null): JourneyCommentsState { - const [loaded, setLoaded] = useState(NOTHING); - const [failedFor, setFailedFor] = useState(null); - const current = loaded.journeyId === journeyId ? loaded : null; - const comments = current?.comments ?? NO_COMMENTS; - const status = journeyId === null ? 'idle' : current ? 'ready' : failedFor === journeyId ? 'failed' : 'loading'; - - const read = useCallback(async (): Promise => { - if (journeyId === null) return null; - try { - const answer = await journeySocialRepo.comments(journeyId); - return { journeyId, comments: answer.comments, canModerate: answer.can_moderate }; - } catch { - // What was read before stays: a thread does not vanish because one read failed. - return null; - } - }, [journeyId]); - - useEffect(() => { - let cancelled = false; - void read().then((next) => { - if (cancelled) return; - if (next) setLoaded(next); - else setFailedFor(journeyId); - }); - return () => { - cancelled = true; - }; - }, [read, journeyId]); - - const reload = useCallback(async () => { - const next = await read(); - if (next) setLoaded(next); - }, [read]); - - useServerPing('journey:entry:commented', journeyId !== null, reload); + const { data, status, update } = useJourneyLiveData(journeyId, 'journey:entry:commented', journeySocialRepo.comments); + const comments = data?.comments ?? NO_COMMENTS; const byEntry = useMemo(() => { const map = new Map(); @@ -83,13 +43,13 @@ export function useJourneyComments(journeyId: number | null): JourneyCommentsSta if (journeyId === null || !body.trim()) return false; try { const comment = await journeySocialRepo.addComment(journeyId, entryId, body); - setLoaded((prev) => (prev.journeyId === journeyId ? { ...prev, comments: [...prev.comments, comment] } : prev)); + update((prev) => (prev ? { ...prev, comments: [...prev.comments, comment] } : null)); return true; } catch { return false; } }, - [journeyId] + [journeyId, update] ); const setHidden = useCallback( @@ -97,16 +57,15 @@ export function useJourneyComments(journeyId: number | null): JourneyCommentsSta if (journeyId === null) return false; try { await journeySocialRepo.setCommentHidden(journeyId, commentId, hidden); - setLoaded((prev) => ({ - ...prev, - comments: prev.comments.map((c) => (c.id === commentId ? { ...c, hidden } : c)), - })); + update((prev) => + prev ? { ...prev, comments: prev.comments.map((c) => (c.id === commentId ? { ...c, hidden } : c)) } : null + ); return true; } catch { return false; } }, - [journeyId] + [journeyId, update] ); const remove = useCallback( @@ -114,14 +73,14 @@ export function useJourneyComments(journeyId: number | null): JourneyCommentsSta if (journeyId === null) return false; try { await journeySocialRepo.deleteComment(journeyId, commentId); - setLoaded((prev) => ({ ...prev, comments: prev.comments.filter((c) => c.id !== commentId) })); + update((prev) => (prev ? { ...prev, comments: prev.comments.filter((c) => c.id !== commentId) } : null)); return true; } catch { return false; } }, - [journeyId] + [journeyId, update] ); - return { comments, byEntry, canModerate: current?.canModerate ?? false, status, add, setHidden, remove }; + return { comments, byEntry, canModerate: data?.can_moderate ?? false, status, add, setHidden, remove }; } diff --git a/client/src/components/Journey/useJourneyLiveData.ts b/client/src/components/Journey/useJourneyLiveData.ts new file mode 100644 index 000000000..e454f4960 --- /dev/null +++ b/client/src/components/Journey/useJourneyLiveData.ts @@ -0,0 +1,54 @@ +import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'; +import { useServerPing } from '../../sync/useServerPing'; + +type LoadStatus = 'idle' | 'loading' | 'ready' | 'failed'; + +/** Read journey data on open and server updates. Keep the last good read when a refresh fails. */ +export function useJourneyLiveData(journeyId: number | null, eventName: string, read: (id: number) => Promise) { + const [loaded, setLoaded] = useState<{ journeyId: number; data: T } | null>(null); + const [failedFor, setFailedFor] = useState(null); + const activeId = useRef(journeyId); + const latestRead = useRef(0); + useLayoutEffect(() => { + activeId.current = journeyId; + return () => { + activeId.current = null; + latestRead.current++; + }; + }, [journeyId]); + + const refresh = useCallback(async () => { + if (journeyId === null) return; + const version = ++latestRead.current; + await read(journeyId).then( + (data) => { + if (latestRead.current === version) setLoaded({ journeyId, data }); + }, + () => { + if (latestRead.current === version) setFailedFor(journeyId); + } + ); + }, [journeyId, read]); + + useEffect(() => { + void refresh(); + }, [refresh]); + + useServerPing(eventName, journeyId !== null, refresh); + + const update = useCallback( + (change: (data: T | null) => T | null) => { + if (journeyId === null || activeId.current !== journeyId) return; + setLoaded((previous) => { + const data = change(previous?.journeyId === journeyId ? previous.data : null); + return data === null ? previous : { journeyId, data }; + }); + }, + [journeyId] + ); + const current = loaded?.journeyId === journeyId ? loaded : null; + const status: LoadStatus = + journeyId === null ? 'idle' : current ? 'ready' : failedFor === journeyId ? 'failed' : 'loading'; + + return { data: current?.data ?? null, status, update }; +} diff --git a/client/src/components/Journey/useJourneyRecordings.ts b/client/src/components/Journey/useJourneyRecordings.ts index 5bc179cd1..b71b2e75e 100644 --- a/client/src/components/Journey/useJourneyRecordings.ts +++ b/client/src/components/Journey/useJourneyRecordings.ts @@ -4,11 +4,11 @@ import { type JourneyRecordingSource, type JourneyTrack, } from '@trek/shared'; -import { useCallback, useEffect, useMemo, useState } from 'react'; +import { useCallback, useMemo, useState } from 'react'; import { useTranslation } from '../../i18n'; import { journeyRecordingsRepo } from '../../repo/journeyRecordingsRepo'; -import { useServerPing } from '../../sync/useServerPing'; import { DAWARICH_TRAIL_COLOR } from '../Map/dawarichTrail'; +import { useJourneyLiveData } from './useJourneyLiveData'; import type { JourneyRecordingViewProps } from './useJourneyRecordingDay'; interface JourneyRecordingsState { @@ -53,52 +53,15 @@ export function useJourneyRecordings( const journeyId = journey?.id ?? null; const journeyTitle = journey?.title ?? ''; const { t, locale } = useTranslation(); - // Held with the journey they belong to, so a journey opened after another - // never shows the other one's days, and nothing has to be reset in an effect. - const [loaded, setLoaded] = useState<{ journeyId: number | null; days: JourneyRecordedDay[] }>(NOTHING_LOADED); + const { data, status, update } = useJourneyLiveData( + journeyId, + 'journey:recording:updated', + journeyRecordingsRepo.list + ); + const days = data ?? NO_DAYS; const [opened, setOpened] = useState<{ journeyId: number | null; date: string | null }>(NOTHING_OPEN); - const [failedFor, setFailedFor] = useState(null); - const days = loaded.journeyId === journeyId ? loaded.days : NO_DAYS; - const status = - journeyId === null - ? 'idle' - : loaded.journeyId === journeyId - ? 'ready' - : failedFor === journeyId - ? 'failed' - : 'loading'; const openDate = opened.journeyId === journeyId ? opened.date : null; - const read = useCallback(async () => { - if (journeyId === null) return null; - try { - return { journeyId, days: await journeyRecordingsRepo.list(journeyId) }; - } catch { - // What was read before stays on the map; a kept day does not vanish - // because one read of it failed. - return null; - } - }, [journeyId]); - - useEffect(() => { - let cancelled = false; - void read().then((next) => { - if (cancelled) return; - if (next) setLoaded(next); - else setFailedFor(journeyId); - }); - return () => { - cancelled = true; - }; - }, [read, journeyId]); - - const reload = useCallback(async () => { - const next = await read(); - if (next) setLoaded(next); - }, [read]); - - useServerPing('journey:recording:updated', journeyId !== null, reload); - const shown = useMemo(() => oneRecordingPerDay(days), [days]); const byDate = useMemo(() => new Map(shown.map((day) => [day.date, day])), [shown]); const bySource = useMemo( @@ -131,16 +94,15 @@ export function useJourneyRecordings( ); const keptMany = useCallback( - (fresh: readonly JourneyRecordedDay[]) => - setLoaded((prev) => ({ journeyId, days: withKeptDays(prev.days, fresh) })), - [journeyId] + (fresh: readonly JourneyRecordedDay[]) => update((prev) => withKeptDays(prev ?? NO_DAYS, fresh)), + [update] ); const kept = useCallback((day: JourneyRecordedDay) => keptMany([day]), [keptMany]); const removed = useCallback( (date: string, source: JourneyRecordingSource = 'dawarich') => - setLoaded((prev) => ({ journeyId, days: prev.days.filter((d) => d.date !== date || d.source !== source) })), - [journeyId] + update((prev) => (prev ?? NO_DAYS).filter((d) => d.date !== date || d.source !== source)), + [update] ); const open = useCallback((date: string) => setOpened({ journeyId, date }), [journeyId]); @@ -178,5 +140,4 @@ export function withKeptDays( /** Stable empty identity, so a journey without kept days never re-renders its map for nothing. */ const NO_DAYS: JourneyRecordedDay[] = []; -const NOTHING_LOADED = { journeyId: null, days: NO_DAYS }; const NOTHING_OPEN = { journeyId: null, date: null }; diff --git a/client/src/components/Journey/useJourneyShareAccess.test.ts b/client/src/components/Journey/useJourneyShareAccess.test.ts index 09333b122..c579f5078 100644 --- a/client/src/components/Journey/useJourneyShareAccess.test.ts +++ b/client/src/components/Journey/useJourneyShareAccess.test.ts @@ -56,7 +56,9 @@ describe('owner access settings', () => { expect(mocks.toast.success).toHaveBeenCalledWith('journey.share.passwordSaved'); await act(async () => result.current.removePassword()); expect(write).toHaveBeenLastCalledWith({ password: null }); - act(() => result.current.setExpiry('')); + await act(async () => { + result.current.setExpiry(''); + }); expect(write).toHaveBeenLastCalledWith({ expires_at: null }); }); diff --git a/client/src/components/Journey/useJourneyShareLink.ts b/client/src/components/Journey/useJourneyShareLink.ts index 7af6d5a9d..c8179b49a 100644 --- a/client/src/components/Journey/useJourneyShareLink.ts +++ b/client/src/components/Journey/useJourneyShareLink.ts @@ -162,7 +162,7 @@ export function useJourneyShareLink(journeyId: number) { const setProtection = async (change: JourneyShareProtectionChange): Promise => { if (!link) return false; try { - await journeyApi.createShareLink(journeyId, change); + await journeyApi.createShareLink(journeyId, { ...change }); setLink((current) => (current ? applyProtection(current, change) : current)); return true; } catch { diff --git a/client/src/components/Studio/StudioTravelInspector.tsx b/client/src/components/Studio/StudioTravelInspector.tsx index 747f5347d..03f2be2bc 100644 --- a/client/src/components/Studio/StudioTravelInspector.tsx +++ b/client/src/components/Studio/StudioTravelInspector.tsx @@ -368,18 +368,7 @@ function MapContent({ el, set, t, stats, journeyPath }: MapPropsInput) { - {el.countries.length > 0 && ((el.source === 'vector' && el.showLand) || el.clip === 'country') && ( -
- ({ - value, - label: t(`journey.studio.mapCoastDetail.${value}`), - }))} - onPick={coastDetail => set({ coastDetail } as Partial)} - /> -
- )} + {el.source === 'tiles' && (
@@ -397,6 +386,23 @@ function MapContent({ el, set, t, stats, journeyPath }: MapPropsInput) { ) } +function MapCoastSection({ el, set, t }: Props) { + const drawsCoast = (el.source === 'vector' && el.showLand) || el.clip === 'country' + if (!drawsCoast || el.countries.length === 0) return null + return ( +
+ ({ + value, + label: t(`journey.studio.mapCoastDetail.${value}`), + }))} + onPick={coastDetail => set({ coastDetail } as Partial)} + /> +
+ ) +} + /** * How a map looks: the line of the route, whether it follows the roads, and * which layers are drawn. After the position, like the look of every kind. diff --git a/client/src/components/Studio/countryDetail.ts b/client/src/components/Studio/countryDetail.ts index 8f101d61a..9ba1f6215 100644 --- a/client/src/components/Studio/countryDetail.ts +++ b/client/src/components/Studio/countryDetail.ts @@ -77,7 +77,7 @@ async function fetchDetail(code: string): Promise { function loadOne(code: string): Promise { if (loaded.has(code)) return Promise.resolve(); const running = inFlight.get(code); - if (running) return running; + if (running !== undefined) return running; const load = fetchDetail(code).then((shape) => { loaded.set(code, shape); inFlight.delete(code); diff --git a/client/src/components/Studio/inspector/inspectorOrder.test.tsx b/client/src/components/Studio/inspector/inspectorOrder.test.tsx index cae478df2..41a4e7f7d 100644 --- a/client/src/components/Studio/inspector/inspectorOrder.test.tsx +++ b/client/src/components/Studio/inspector/inspectorOrder.test.tsx @@ -175,6 +175,7 @@ describe('the order of the groups', () => { expect(groups(m.container)).toEqual([ 'journey.studio.routeMap', 'journey.studio.mapFraming', + 'journey.studio.mapCoastDetail', 'journey.studio.position', 'journey.studio.routeLook', 'journey.studio.mapLayers', diff --git a/client/src/mobile/screens/journey/MJourneySettingsSheet.tsx b/client/src/mobile/screens/journey/MJourneySettingsSheet.tsx index cc811e691..a1993f773 100644 --- a/client/src/mobile/screens/journey/MJourneySettingsSheet.tsx +++ b/client/src/mobile/screens/journey/MJourneySettingsSheet.tsx @@ -56,11 +56,6 @@ export default function MJourneySettingsSheet({ journeyId: journey.id, onLinked: () => { setAddTripOpen(false); onRefresh() }, }) - const { - link: shareLink, copied, shareUrl, createLink: createShareLink, togglePerm: toggleSharePerm, - deleteLink: deleteShareLink, copyLink: copyShareUrl, setProtection, - } = useJourneyShareLink(journey.id) - const shareAccess = useJourneyShareAccess(journey.id, shareLink, setProtection) const coverRef = useRef(null) const coverSrc = journeyCoverSrc(journey.cover_image) @@ -241,72 +236,7 @@ export default function MJourneySettingsSheet({ - - {!shareLink ? ( - - ) : ( - <> - {shareUrl && ( - - )} - {shareAccess.views > 0 && ( -
- - {t('journey.share.views', { count: shareAccess.views })} - {shareAccess.lastViewed && {t('journey.share.lastViewed', { date: shareAccess.lastViewed })}} -
- )} - {([ - { key: 'share_timeline' as const, label: t('journey.share.timeline'), icon: List }, - { key: 'share_gallery' as const, label: t('journey.share.gallery'), icon: Grid3x3 }, - { key: 'share_map' as const, label: t('journey.share.map'), icon: MapPin }, - ]).map(({ key, label, icon: Icon }) => ( - } - label={label} - checked={shareLink[key]} - onChange={() => toggleSharePerm(key)} - /> - ))} - - } - label={t('journey.share.allowComments')} - hint={shareLink.share_timeline ? t('journey.share.allowCommentsHint') : t('journey.share.needsTimeline')} - checked={!!shareLink.share_timeline && !!shareLink.allow_comments} - disabled={!shareLink.share_timeline} - onChange={() => { void toggleSharePerm('allow_comments') }} - /> - } - label={t('journey.share.allowFollowers')} - hint={t('journey.share.allowFollowersHint')} - checked={!!shareLink.allow_subscriptions} - onChange={() => { void toggleSharePerm('allow_subscriptions') }} - /> - {shareLink.allow_subscriptions && } - - - - )} -
+ + ) : ( + <> + {shareUrl && ( + + )} + {shareAccess.views > 0 && ( +
+ + {t('journey.share.views', { count: shareAccess.views })} + {shareAccess.lastViewed && {t('journey.share.lastViewed', { date: shareAccess.lastViewed })}} +
+ )} + {([ + { key: 'share_timeline' as const, label: t('journey.share.timeline'), icon: List }, + { key: 'share_gallery' as const, label: t('journey.share.gallery'), icon: Grid3x3 }, + { key: 'share_map' as const, label: t('journey.share.map'), icon: MapPin }, + ]).map(({ key, label, icon: Icon }) => ( + } + label={label} + checked={shareLink[key]} + onChange={() => toggleSharePerm(key)} + /> + ))} + + } + label={t('journey.share.allowComments')} + hint={shareLink.share_timeline ? t('journey.share.allowCommentsHint') : t('journey.share.needsTimeline')} + checked={!!shareLink.share_timeline && !!shareLink.allow_comments} + disabled={!shareLink.share_timeline} + onChange={() => { void toggleSharePerm('allow_comments') }} + /> + } + label={t('journey.share.allowFollowers')} + hint={t('journey.share.allowFollowersHint')} + checked={!!shareLink.allow_subscriptions} + onChange={() => { void toggleSharePerm('allow_subscriptions') }} + /> + {shareLink.allow_subscriptions && } + + + + )} + + ) +} + type ShareAccess = ReturnType /** The addresses following the link (#1669): two counts, the list behind them. */ diff --git a/client/src/pages/JourneyFollowPage.tsx b/client/src/pages/JourneyFollowPage.tsx index b54d3abb1..3a2c79903 100644 --- a/client/src/pages/JourneyFollowPage.tsx +++ b/client/src/pages/JourneyFollowPage.tsx @@ -1,5 +1,5 @@ import { BellOff, BellRing, CircleAlert, Loader2 } from 'lucide-react'; -import { Link } from 'react-router-dom'; +import { Link } from 'react-router'; import { useTranslation } from '../i18n'; import { useJourneyFollowPage } from './journeyFollow/useJourneyFollowPage'; diff --git a/client/src/pages/JourneyPublicPage.tsx b/client/src/pages/JourneyPublicPage.tsx index fbabfcfb0..a681cf5c8 100644 --- a/client/src/pages/JourneyPublicPage.tsx +++ b/client/src/pages/JourneyPublicPage.tsx @@ -565,7 +565,7 @@ function JourneyPublicContent() { )} {social.commentsOpen && ( -
+
)} diff --git a/client/src/pages/journeyDetail/useJourneyDetailLayers.ts b/client/src/pages/journeyDetail/useJourneyDetailLayers.ts index f503e32e9..53cdfdd7b 100644 --- a/client/src/pages/journeyDetail/useJourneyDetailLayers.ts +++ b/client/src/pages/journeyDetail/useJourneyDetailLayers.ts @@ -95,20 +95,13 @@ export function useJourneyDetailLayers({ ].join('|'), [current?.entries, current?.trips, showTripTracks] ); - // The kept days and the live trail are read by this screen, not by the layers' read. - const recordedRead = - recordings.status === 'failed' || dawarichTrail.status === 'unavailable' - ? 'unavailable' - : recordings.status === 'loading' || dawarichTrail.status === 'loading' - ? 'loading' - : 'ready'; const mapLayers = useJourneyMapLayers({ source: journeyLoaded && current ? { journeyId: current.id } : null, refreshKey: mapRefreshKey, entryIdsOnMap, photoCount, recordedTracks: mapTracks, - recordedRead, + recordedRead: recordedLayerStatus(recordings.status, dawarichTrail.status), colorOfDay, dateOfEntry, }); @@ -154,3 +147,13 @@ export function useJourneyDetailLayers({ dayImportDates, }; } + +/** A failed route source stays visible as unavailable while the other layers load. */ +function recordedLayerStatus( + recordings: ReturnType['recordings']['status'], + dawarich: ReturnType['status'] +): 'unavailable' | 'loading' | 'ready' { + if (recordings === 'failed' || dawarich === 'unavailable') return 'unavailable'; + if (recordings === 'loading' || dawarich === 'loading') return 'loading'; + return 'ready'; +} diff --git a/client/src/pages/journeyFollow/useJourneyFollowPage.ts b/client/src/pages/journeyFollow/useJourneyFollowPage.ts index 22c7bacab..622a18695 100644 --- a/client/src/pages/journeyFollow/useJourneyFollowPage.ts +++ b/client/src/pages/journeyFollow/useJourneyFollowPage.ts @@ -1,4 +1,4 @@ -import { useParams, useSearchParams } from 'react-router-dom'; +import { useParams, useSearchParams } from 'react-router'; import { useJourneyFollow } from './useJourneyFollow'; /** diff --git a/client/src/pages/journeyPublic/JourneyPublicFollow.tsx b/client/src/pages/journeyPublic/JourneyPublicFollow.tsx index 27397958b..91c45d258 100644 --- a/client/src/pages/journeyPublic/JourneyPublicFollow.tsx +++ b/client/src/pages/journeyPublic/JourneyPublicFollow.tsx @@ -47,8 +47,8 @@ export function JourneyPublicFollow({ setError(null); }; - const submit = async (e: FormEvent) => { - e.preventDefault(); + const submit = async (e?: FormEvent) => { + e?.preventDefault(); if (busy || sent || !email.trim()) return; // Only a bot fills the field people never see: it is told all went well. if (trap) { @@ -68,7 +68,7 @@ export function JourneyPublicFollow({