feat(journey): complete sharing, photo drafts and Studio maps

Connect the Journey backend to the web and mobile UI, including public access and subscriptions, day recordings, photo drafts and per-map framing. Preserve legacy recording responses and cover the new behavior in every locale.
This commit is contained in:
Maurice
2026-11-30 16:55:22 +01:00
parent 458227f489
commit ede109dce8
90 changed files with 5306 additions and 292 deletions
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, type CSSProperties, type ReactNode } from 'react'
import { Outlet, useSearchParams } from 'react-router'
import { BookOpen, ChevronLeft, MapPin, Grid3x3, Map as MapIcon, MoreHorizontal, Play, Image, Camera, EyeOff, Satellite, Settings2, X, Route, ListChecks } from 'lucide-react'
import { BookOpen, ChevronLeft, MapPin, Grid3x3, Map as MapIcon, MoreHorizontal, Play, Image, Camera, EyeOff, Satellite, Settings2, X, Route, ListChecks, FileUp, Trash2, NotebookPen } from 'lucide-react'
import JourneyLayeredMap from '../../../components/Journey/JourneyLayeredMap'
import type { BaseLayer } from '../../../components/Map/MapLayerSwitcher'
import PhotoLightbox from '../../../components/Journey/PhotoLightbox'
@@ -29,7 +29,9 @@ import { useGalleryUpload } from '../../../components/Journey/useGalleryUpload'
import { dayPrepText, dayPrepUnsettled } from '../../../components/Journey/journeyRecordingPrepModel'
import MJourneyEntrySheet from './MJourneyEntrySheet'
import { useIsSplit, useIsWide } from '../../../hooks/sizeClass'
import { MemberEntryComments } from '../../../components/Journey/JourneyEntryComments'
import MJourneyFeed from './MJourneyFeed'
import MJourneyFromPhotosSheet from './MJourneyFromPhotosSheet'
import MJourneySettingsSheet from './MJourneySettingsSheet'
import MJourneyDayImportSheet from './MJourneyDayImportSheet'
import MJourneyRecordingSheet from './MJourneyRecordingSheet'
@@ -86,9 +88,10 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD
showSettings, setShowSettings,
hideSkeletons, setHideSkeletons,
sidebarMapItems, tracks, mapLayers, entryTitleOf, mapPhotos, openMapPhotos, recordings, canTakeOverRecording, dayImport, dayImportDates, dawarichByDate, recordingPrep,
gpxImport, canImportGpx,
dismissSuggestion, restoreSuggestions, openAtEntryId,
loadJourney, updateEntry, deleteEntry, reorderEntries, uploadPhotos,
addPickedProviderPhotos, addEntryProviderPhotos, writeAboutPlace,
addPickedProviderPhotos, addEntryProviderPhotos, writeAboutPlace, comments,
} = useJourneyDetail({ journeyId, embedded })
// A trip tab: the header goes into the trip shell's top row (tabHeadSlot.ts).
const shellSlot = useTabHeadSlot()
@@ -216,6 +219,15 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD
// The map's base, switched from the bar: the satellite imagery or the map (#2594).
const [mapBase, setMapBase] = useState<BaseLayer>('default')
const [showActionMenu, setShowActionMenu] = useState(false)
// #3085: the day a GPX file is being picked for, and the hidden picker itself.
const gpxFileRef = useRef<HTMLInputElement>(null)
const gpxDateRef = useRef<string | null>(null)
const pickGpxFor = (date: string) => {
setShowActionMenu(false)
gpxDateRef.current = date
gpxFileRef.current?.click()
}
const [showFromPhotos, setShowFromPhotos] = useState(false)
const [pickerProvider, setPickerProvider] = useState<string | null>(null)
// The gallery photo waiting on its delete confirm; entries have their own deleteTarget.
const [photoDeleteTarget, setPhotoDeleteTarget] = useState<GalleryPhoto | null>(null)
@@ -677,7 +689,7 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD
{/* The recorded route of the day the card rail is on (JRN-01): taking it
over, or checking, replacing or dropping the one kept. */}
{canEditEntries && view === 'timeline' && entries[activeIndex] &&
(canTakeOverRecording || recordings.byDate.has(entries[activeIndex].entry_date)) && (
(canTakeOverRecording || recordings.bySource.dawarich.has(entries[activeIndex].entry_date)) && (
<MListRow
icon={Route}
label={t('journey.recording.takeOverDay', {
@@ -686,6 +698,37 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD
onClick={() => { setShowActionMenu(false); recordings.open(entries[activeIndex].entry_date) }}
/>
)}
{/* #1920: the gallery's loose photos as drafts. */}
{canEditEntries && view === 'gallery' && gallery.length > 0 && (
<MListRow
icon={NotebookPen}
label={t('journey.fromPhotos.title')}
onClick={() => { setShowActionMenu(false); setShowFromPhotos(true) }}
/>
)}
{/* The day's route from a GPX file (#3085), with or without Dawarich. */}
{canEditEntries && canImportGpx && !gpxImport.busy && view === 'timeline' && entries[activeIndex] && (
recordings.bySource.gpx.has(entries[activeIndex].entry_date) ? (
<>
<MListRow
icon={FileUp}
label={t('journey.recording.replace')}
onClick={() => pickGpxFor(entries[activeIndex].entry_date)}
/>
<MListRow
icon={Trash2}
label={t('journey.recording.remove')}
onClick={() => { setShowActionMenu(false); void gpxImport.removeDay(entries[activeIndex].entry_date) }}
/>
</>
) : (
<MListRow
icon={FileUp}
label={t('journey.recording.gpx.import')}
onClick={() => pickGpxFor(entries[activeIndex].entry_date)}
/>
)
)}
{/* The same day with its stays (JRN-02), counting the ones still waiting. */}
{canEditEntries && canTakeOverRecording && view === 'timeline' && entries[activeIndex] &&
dayImportRow(entries[activeIndex].entry_date, () => setShowActionMenu(false))}
@@ -699,6 +742,32 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD
</div>
</MSheet>
<input
ref={gpxFileRef}
type="file"
accept=".gpx,application/gpx+xml"
className="hidden"
onChange={e => {
const file = e.target.files?.[0]
const date = gpxDateRef.current
gpxDateRef.current = null
e.target.value = ''
if (file && date) void gpxImport.importDayFile(file, date)
}}
/>
{showFromPhotos && (
<MJourneyFromPhotosSheet
journeyId={current.id}
coverOf={id => {
const photo = gallery.find(p => p.id === id)
return photo && !posterlessVideo(photo) ? photoUrl(photo, 'thumbnail') : null
}}
onCreated={() => { void loadJourney(current.id) }}
onClose={() => setShowFromPhotos(false)}
/>
)}
{/* Entry sheet (new / edit / read-only) */}
{editingEntry && (
<MJourneyEntrySheet
@@ -706,6 +775,7 @@ export default function MJourneyDetail({ journeyId, embedded = false }: JourneyD
galleryPhotos={gallery}
quickCapture={editingEntry.id === 0}
readOnly={!canEditEntries || readingEntry}
comments={editingEntry.id > 0 && editingEntry.type !== 'skeleton' ? <MemberEntryComments entryId={editingEntry.id} thread={comments} defaultOpen /> : undefined}
onEdit={readingEntry ? () => setEditEntryId(editingEntry.id) : undefined}
showVerdict={current.show_verdict !== 0}
showMood={current.show_mood !== 0}
@@ -1,4 +1,4 @@
import { useRef, useState, type CSSProperties } from 'react'
import { useRef, useState, type CSSProperties, type ReactNode } from 'react'
import { Briefcase, Camera, Plus, Image, Images, X, MapPin, Locate, Trash2, CheckCircle2, MinusCircle, ChevronUp, ChevronDown, EyeOff, Play, NotebookPen, Pencil } from 'lucide-react'
import { useIsTouch } from '../../../hooks/useIsTouch'
import { useTouchDragBridge } from '../../../hooks/useTouchDragBridge'
@@ -87,6 +87,8 @@ interface MJourneyEntrySheetProps {
onAddProviderPhotos?: (entryId: number, group: PendingProviderGroup) => Promise<void>
onDelete?: () => void
onDone: () => void
/** The comment thread under the entry (#1702), shown while it is read. */
comments?: ReactNode
}
/**
@@ -97,7 +99,7 @@ interface MJourneyEntrySheetProps {
export default function MJourneyEntrySheet({
entry, galleryPhotos, quickCapture = false, readOnly = false, userId = 0, trips = [], photoProviders: providers = NO_PROVIDERS,
showVerdict = true, showMood = true, showWeather = true, onEdit, onMoveEarlier, onMoveLater, onDismiss,
onClose, onSave, onUploadPhotos, onAddProviderPhotos, onDelete, onDone,
onClose, onSave, onUploadPhotos, onAddProviderPhotos, onDelete, onDone, comments,
}: MJourneyEntrySheetProps) {
const { t, language } = useTranslation()
const {
@@ -769,6 +771,12 @@ export default function MJourneyEntrySheet({
<span className="min-w-0 flex-1 text-[0.8125rem] font-semibold">{t('journey.suggestions.dismiss')}</span>
</button>
)}
{readOnly && comments && (
<>
<div className={`${eyebrow} mb-[6px] mt-4`}>{t('journey.comments.title')}</div>
<div className={`${fieldShell} rounded-[14px] px-3 py-3`}>{comments}</div>
</>
)}
</FormSheetBody>
<div className="m-fs-foot flex flex-none items-center gap-2 border-t border-[color:var(--m-rowbr)] px-[18px] pb-4 pt-3">
@@ -0,0 +1,59 @@
import { Images } from 'lucide-react';
import JourneyFromPhotosList from '../../../components/Journey/JourneyFromPhotosList';
import { useJourneyEntriesFromPhotos } from '../../../components/Journey/useJourneyEntriesFromPhotos';
import { useTranslation } from '../../../i18n';
import MSheet from '../../components/MSheet';
import { SHEET_PRIMARY, SHEET_SECONDARY } from '../trip/sheets/MTripSheetUi';
import { FormSheetHeader } from '../trip/sheets/PlSheetChrome';
/** "Entries from photos" on the phone (#1920), on the same hook and list as the desktop dialog. */
export default function MJourneyFromPhotosSheet({
journeyId,
coverOf,
onCreated,
onClose,
}: {
journeyId: number;
coverOf: (galleryPhotoId: number) => string | null;
onCreated: () => void;
onClose: () => void;
}) {
const { t } = useTranslation();
const state = useJourneyEntriesFromPhotos({ journeyId, onCreated, onClose });
const allOn = state.clusters.length > 0 && state.selectedCount === state.clusters.length;
return (
<MSheet open onClose={onClose} variant="bottom" material="glass" ariaLabel={t('journey.fromPhotos.title')}>
<div className="flex max-h-[86dvh] min-h-0 flex-col">
<FormSheetHeader
icon={Images}
title={t('journey.fromPhotos.title')}
subtitle={t('journey.fromPhotos.text')}
onClose={onClose}
closeLabel={t('common.close')}
/>
<div className="min-h-0 flex-1 overflow-y-auto px-[14px] pb-3">
<JourneyFromPhotosList state={state} coverOf={coverOf} />
</div>
<div className="flex flex-none items-center gap-2 border-t border-[color:var(--m-rowbr)] px-[18px] pb-4 pt-3">
{state.clusters.length > 1 && (
<button
type="button"
onClick={() => state.selectAll(!allOn)}
className={`${SHEET_SECONDARY} whitespace-nowrap`}
>
{allOn ? t('common.deselectAll') : t('common.selectAll')}
</button>
)}
<button
type="button"
disabled={!state.canSubmit}
onClick={state.submit}
className={`${SHEET_PRIMARY} flex-1 justify-center disabled:opacity-50`}
>
{t('journey.fromPhotos.create', { count: state.selectedCount })}
</button>
</div>
</div>
</MSheet>
);
}
@@ -1,5 +1,5 @@
import { useRef, useState, type ReactNode } from 'react'
import { Image, Plus, Trash2, UserPlus, UserMinus, Unlink, Settings2, Link as LinkIcon, List, Grid3x3, MapPin, Route, Archive, ArchiveRestore, Undo2, Link2, ListChecks, RefreshCw } from 'lucide-react'
import { Image, Plus, Trash2, UserPlus, UserMinus, Unlink, Settings2, Link as LinkIcon, List, Grid3x3, MapPin, Route, Archive, ArchiveRestore, Undo2, Link2, ListChecks, RefreshCw, MessageCircle, BellPlus, Lock, CalendarClock, Eye, X } from 'lucide-react'
import MLinkField from '../../components/MLinkField'
import MSheet from '../../components/MSheet'
import {
@@ -20,6 +20,8 @@ import { useJourneySettings, useJourneyTripLinking } from '../../../components/J
import {
SHARE_MAP_EXTRAS, useJourneyShareLink, type JourneyShareLink, type JourneyShareMapExtra,
} from '../../../components/Journey/useJourneyShareLink'
import { useJourneyShareAccess } from '../../../components/Journey/useJourneyShareAccess'
import JourneySharePasswordDialog from '../../../components/Journey/JourneySharePasswordDialog'
import type { JourneyRecordingPrepState } from '../../../components/Journey/useJourneyRecordingPrep'
import { pickGradient } from '../../../pages/journeyDetail/JourneyDetailPage.helpers'
import { journeyCoverSrc } from './mobileJourneyMeta'
@@ -56,8 +58,9 @@ export default function MJourneySettingsSheet({
})
const {
link: shareLink, copied, shareUrl, createLink: createShareLink, togglePerm: toggleSharePerm,
deleteLink: deleteShareLink, copyLink: copyShareUrl,
deleteLink: deleteShareLink, copyLink: copyShareUrl, setProtection,
} = useJourneyShareLink(journey.id)
const shareAccess = useJourneyShareAccess(journey.id, shareLink, setProtection)
const coverRef = useRef<HTMLInputElement>(null)
const coverSrc = journeyCoverSrc(journey.cover_image)
@@ -256,6 +259,13 @@ export default function MJourneySettingsSheet({
shareLabel={t('common.share')}
/>
)}
{shareAccess.views > 0 && (
<div className="flex items-center gap-1.5 ps-1 font-geist text-caption text-m-muted">
<Eye size={12} strokeWidth={2} />
<span>{t('journey.share.views', { count: shareAccess.views })}</span>
{shareAccess.lastViewed && <span>{t('journey.share.lastViewed', { date: shareAccess.lastViewed })}</span>}
</div>
)}
{([
{ key: 'share_timeline' as const, label: t('journey.share.timeline'), icon: List },
{ key: 'share_gallery' as const, label: t('journey.share.gallery'), icon: Grid3x3 },
@@ -270,6 +280,23 @@ export default function MJourneySettingsSheet({
/>
))}
<MShareMapExtras link={shareLink} onToggle={toggleSharePerm} />
<ToggleRow
icon={<MessageCircle size={16} strokeWidth={2} />}
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') }}
/>
<ToggleRow
icon={<BellPlus size={16} strokeWidth={2} />}
label={t('journey.share.allowFollowers')}
hint={t('journey.share.allowFollowersHint')}
checked={!!shareLink.allow_subscriptions}
onChange={() => { void toggleSharePerm('allow_subscriptions') }}
/>
{shareLink.allow_subscriptions && <MShareFollowers access={shareAccess} />}
<MShareAccess access={shareAccess} />
<button
type="button"
onClick={deleteShareLink}
@@ -410,6 +437,83 @@ function MRecordingPrepRow({ prep, enabled }: { prep: JourneyRecordingPrepState;
)
}
type ShareAccess = ReturnType<typeof useJourneyShareAccess>
/** The addresses following the link (#1669): two counts, the list behind them. */
function MShareFollowers({ access }: { access: ShareAccess }) {
const { t } = useTranslation()
const { followers } = access
if (followers.status !== 'ready' || (followers.count === 0 && followers.pending === 0)) return null
return (
<div className="mb-1 ms-[9px] border-s-2 border-[color:var(--m-rowbr)] ps-[16px]">
<button
type="button"
aria-expanded={access.followersOpen}
onClick={() => access.setFollowersOpen(!access.followersOpen)}
className="flex flex-wrap items-center gap-1.5 py-[7px] font-geist text-caption"
>
<span className="rounded-full bg-[color:var(--m-ic)] px-2 py-0.5 font-semibold text-m-ink">{t('journey.share.followers', { count: followers.count })}</span>
{followers.pending > 0 && (
<span className="rounded-full bg-[color:var(--m-ic)] px-2 py-0.5 text-m-muted">{t('journey.share.followersPending', { count: followers.pending })}</span>
)}
</button>
{access.followersOpen && followers.subscribers.map(sub => (
<div key={sub.id} className="flex items-center gap-2">
<span className={`min-w-0 flex-1 truncate font-geist text-caption ${sub.confirmed ? 'text-m-ink' : 'text-m-muted'}`}>{sub.email}</span>
<button
type="button"
aria-label={t('journey.share.removeFollower')}
onClick={() => void access.removeFollower(sub.id)}
className="flex h-10 w-10 flex-none items-center justify-center text-m-muted"
>
<X size={14} strokeWidth={2.2} />
</button>
</div>
))}
</div>
)
}
/** Password and end date of the link (#2553), one row each. */
function MShareAccess({ access }: { access: ShareAccess }) {
const { t } = useTranslation()
return (
<div className="flex flex-col gap-[6px]">
<div className="flex items-center gap-[11px] rounded-[14px] bg-[color:var(--m-ic)] px-3 py-[10px]">
<Lock size={16} strokeWidth={2} className="flex-none text-m-muted" />
<div className="min-w-0 flex-1 text-body font-semibold text-m-ink">{t('common.password')}</div>
{access.hasPassword && (
<button type="button" onClick={() => void access.removePassword()} className="px-1 font-geist text-caption font-semibold text-[color:var(--m-st-danger)]">
{t('common.remove')}
</button>
)}
<button type="button" onClick={() => access.setPasswordOpen(true)} className="rounded-full bg-m-sheetop px-3 py-1.5 font-geist text-caption font-semibold text-m-ink">
{access.hasPassword ? t('common.change') : t('journey.share.passwordSet')}
</button>
</div>
<div className="flex items-center gap-[11px] rounded-[14px] bg-[color:var(--m-ic)] px-3 py-[10px]">
<CalendarClock size={16} strokeWidth={2} className="flex-none text-m-muted" />
<div className="min-w-0 flex-1 text-body font-semibold text-m-ink">{t('journey.share.expires')}</div>
{!access.expiry && <span className="font-geist text-caption text-m-muted">{t('journey.share.expiresNever')}</span>}
<input
type="date"
value={access.expiry}
min={access.minExpiry}
onChange={e => access.setExpiry(e.target.value)}
aria-label={t('journey.share.expires')}
className="bg-transparent font-geist text-caption text-m-ink outline-none"
/>
{access.expiry && (
<button type="button" aria-label={t('journey.share.expiresNever')} onClick={() => access.setExpiry('')} className="flex h-8 w-8 flex-none items-center justify-center text-m-muted">
<X size={14} strokeWidth={2.2} />
</button>
)}
</div>
{access.passwordOpen && <JourneySharePasswordDialog onSave={access.savePassword} onClose={() => access.setPasswordOpen(false)} />}
</div>
)
}
/** What the shared map shows besides the entries (JRN-04), only while the map is shared. */
function MShareMapExtras({ link, onToggle }: { link: JourneyShareLink; onToggle: (key: JourneyShareMapExtra) => unknown }) {
const { t } = useTranslation()