mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 09:54:14 +00:00
fix(journey): stop the entry views from shifting while photos and providers load
Opening an entry on the share page showed the hero at no height until the original arrived, then pushed the story down, and the lightbox stayed black until the full photo had loaded. The hero now reserves the photo's proportions (4:3 when none were recorded) with its thumbnail behind it, and the lightbox shows the thumbnail and a spinner until the original is in. The phone entry sheet probed the photo providers again on every open and added the External photos button once the answer came, squeezing the icons of the other two buttons. The journey screen already knows the connected providers, so it hands them to the sheet, and the icons keep their size. The picked neutral mood was a grey tint on a grey sheet; a picked mood is now framed in its full colour and announced as pressed. Closes #2907 Closes #2908 Closes #2905
This commit is contained in:
@@ -213,7 +213,7 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
|
||||
onClose={() => setViewingEntry(null)}
|
||||
onEdit={() => { setViewingEntry(null); setEditingEntry(viewingEntry); }}
|
||||
onDelete={() => { setViewingEntry(null); setDeleteTarget(viewingEntry); }}
|
||||
onPhotoClick={(photos, idx) => setLightbox({ photos: photos.map(p => ({ id: p.id, src: photoUrl(p, 'original'), caption: p.caption, provider: p.provider, asset_id: p.asset_id, owner_id: p.owner_id, mediaType: p.media_type })), index: idx })}
|
||||
onPhotoClick={(photos, idx) => setLightbox({ photos: photos.map(p => ({ id: p.id, src: photoUrl(p, 'original'), thumbSrc: photoUrl(p, 'thumbnail'), caption: p.caption, provider: p.provider, asset_id: p.asset_id, owner_id: p.owner_id, mediaType: p.media_type })), index: idx })}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -602,7 +602,7 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
|
||||
readOnly={!canEditEntries}
|
||||
onEdit={() => setEditingEntry(entry)}
|
||||
onDelete={() => setDeleteTarget(entry)}
|
||||
onPhotoClick={(photos, idx) => setLightbox({ photos: photos.map(p => ({ id: p.id, src: photoUrl(p, 'original'), caption: p.caption, provider: p.provider, asset_id: p.asset_id, owner_id: p.owner_id, mediaType: p.media_type })), index: idx })}
|
||||
onPhotoClick={(photos, idx) => setLightbox({ photos: photos.map(p => ({ id: p.id, src: photoUrl(p, 'original'), thumbSrc: photoUrl(p, 'thumbnail'), caption: p.caption, provider: p.provider, asset_id: p.asset_id, owner_id: p.owner_id, mediaType: p.media_type })), index: idx })}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -656,7 +656,7 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
|
||||
userId={useAuthStore.getState().user?.id || 0}
|
||||
trips={current.trips}
|
||||
canEdit={canEditEntries}
|
||||
onPhotoClick={(photos, idx) => setLightbox({ photos: photos.map(p => ({ id: p.id, src: photoUrl(p, 'original'), caption: p.caption ?? null, provider: p.provider, asset_id: p.asset_id, owner_id: p.owner_id, mediaType: p.media_type })), index: idx })}
|
||||
onPhotoClick={(photos, idx) => setLightbox({ photos: photos.map(p => ({ id: p.id, src: photoUrl(p, 'original'), thumbSrc: photoUrl(p, 'thumbnail'), caption: p.caption ?? null, provider: p.provider, asset_id: p.asset_id, owner_id: p.owner_id, mediaType: p.media_type })), index: idx })}
|
||||
onRefresh={() => loadJourney(Number(id))}
|
||||
onAddProviderPhotos={addPickedProviderPhotos}
|
||||
/>
|
||||
@@ -735,7 +735,7 @@ export function JourneyDetailPageDesktop({ journeyId, embedded = false }: Journe
|
||||
const entry = current.entries.find(e => String(e.id) === entryId)
|
||||
if (!entry?.photos?.length) return
|
||||
setLightbox({
|
||||
photos: entry.photos.map(p => ({ id: p.id, src: photoUrl(p, 'original'), caption: p.caption, provider: p.provider, asset_id: p.asset_id, owner_id: p.owner_id, mediaType: p.media_type })),
|
||||
photos: entry.photos.map(p => ({ id: p.id, src: photoUrl(p, 'original'), thumbSrc: photoUrl(p, 'thumbnail'), caption: p.caption, provider: p.provider, asset_id: p.asset_id, owner_id: p.owner_id, mediaType: p.media_type })),
|
||||
index,
|
||||
})
|
||||
}}
|
||||
|
||||
@@ -72,6 +72,20 @@ function photoUrl(p: { photo_id: number }, shareToken: string, kind: 'thumbnail'
|
||||
return `/api/public/journey/${shareToken}/photos/${p.photo_id}/${kind}`;
|
||||
}
|
||||
|
||||
type SharedPhoto = { id: number | string; photo_id: number; caption?: string | null; media_type?: string | null };
|
||||
|
||||
// The lightbox opens on the original and shows the thumbnail the page already
|
||||
// loaded until it arrives, instead of a black screen (#2907).
|
||||
function lightboxPhoto(p: SharedPhoto, shareToken: string) {
|
||||
return {
|
||||
id: String(p.id),
|
||||
src: photoUrl(p, shareToken, 'original'),
|
||||
thumbSrc: photoUrl(p, shareToken, 'thumbnail'),
|
||||
caption: p.caption ?? null,
|
||||
mediaType: p.media_type,
|
||||
};
|
||||
}
|
||||
|
||||
// The share route answers 404 for the thumbnail of a clip that has no poster, and
|
||||
// an <img> pointed at it draws the broken-image glyph (#2341). The black ground
|
||||
// the layouts give a video stands in for the picture.
|
||||
@@ -172,12 +186,7 @@ export default function JourneyPublicPage() {
|
||||
const picked = allPhotos.filter((p) => wanted.has(String(p.id)));
|
||||
if (!token || picked.length === 0) return;
|
||||
setLightbox({
|
||||
photos: picked.map((p) => ({
|
||||
id: String(p.id),
|
||||
src: photoUrl(p, token, 'original'),
|
||||
caption: p.caption,
|
||||
mediaType: p.media_type,
|
||||
})),
|
||||
photos: picked.map((p) => lightboxPhoto(p, token)),
|
||||
index: 0,
|
||||
});
|
||||
};
|
||||
@@ -243,12 +252,7 @@ export default function JourneyPublicPage() {
|
||||
const prosArr = entry.pros_cons?.pros ?? [];
|
||||
const consArr = entry.pros_cons?.cons ?? [];
|
||||
const hasProscons = prosArr.length > 0 || consArr.length > 0;
|
||||
const lightboxPhotos = photos.map((p) => ({
|
||||
id: String(p.id),
|
||||
src: photoUrl(p, token!, 'original'),
|
||||
caption: p.caption,
|
||||
mediaType: p.media_type,
|
||||
}));
|
||||
const lightboxPhotos = photos.map((p) => lightboxPhoto(p, token!));
|
||||
|
||||
const isActive = activeEntryId === String(entry.id);
|
||||
return (
|
||||
@@ -559,12 +563,7 @@ export default function JourneyPublicPage() {
|
||||
className="relative block aspect-square w-full cursor-pointer overflow-hidden rounded-lg"
|
||||
onClick={() =>
|
||||
setLightbox({
|
||||
photos: allPhotos.map((p) => ({
|
||||
id: String(p.id),
|
||||
src: photoUrl(p, token!, 'original'),
|
||||
caption: p.caption,
|
||||
mediaType: p.media_type,
|
||||
})),
|
||||
photos: allPhotos.map((p) => lightboxPhoto(p, token!)),
|
||||
index: idx,
|
||||
})
|
||||
}
|
||||
@@ -760,12 +759,7 @@ export default function JourneyPublicPage() {
|
||||
onDelete={() => { }}
|
||||
onPhotoClick={(photos, idx) =>
|
||||
setLightbox({
|
||||
photos: photos.map((p) => ({
|
||||
id: String(p.id),
|
||||
src: photoUrl(p as any, token!, 'original'),
|
||||
caption: (p as any).caption ?? null,
|
||||
mediaType: p.media_type,
|
||||
})),
|
||||
photos: photos.map((p) => lightboxPhoto(p, token!)),
|
||||
index: idx,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -470,7 +470,7 @@ export function useJourneyDetail({ journeyId, embedded = false }: JourneyDetailO
|
||||
const photos = (current?.gallery ?? []).filter(p => wanted.has(String(p.id)))
|
||||
if (!photos.length) return
|
||||
setLightbox({
|
||||
photos: photos.map(p => ({ id: p.id, src: photoUrl(p, 'original'), caption: p.caption, provider: p.provider, asset_id: p.asset_id, owner_id: p.owner_id, mediaType: p.media_type })),
|
||||
photos: photos.map(p => ({ id: p.id, src: photoUrl(p, 'original'), thumbSrc: photoUrl(p, 'thumbnail'), caption: p.caption, provider: p.provider, asset_id: p.asset_id, owner_id: p.owner_id, mediaType: p.media_type })),
|
||||
index: 0,
|
||||
})
|
||||
}, [current?.gallery])
|
||||
|
||||
@@ -26,7 +26,7 @@ export function useJourneyPublic() {
|
||||
const [error, setError] = useState(false)
|
||||
const isMobile = useIsMobile()
|
||||
const [view, setView] = useState<'timeline' | 'gallery' | 'map'>('timeline')
|
||||
const [lightbox, setLightbox] = useState<{ photos: { id: string; src: string; caption?: string | null; mediaType?: string | null }[]; index: number } | null>(null)
|
||||
const [lightbox, setLightbox] = useState<{ photos: { id: string; src: string; thumbSrc?: string; caption?: string | null; mediaType?: string | null }[]; index: number } | null>(null)
|
||||
const [showLangPicker, setShowLangPicker] = useState(false)
|
||||
const locale = useSettingsStore(s => s.settings.language) || 'en'
|
||||
const mapRef = useRef<JourneyMapHandle>(null)
|
||||
|
||||
Reference in New Issue
Block a user