forked from BRETT/BRETT
Record where an upload was opened from in a new useUploadNavContext state. When a tile is clicked on a user profile, the thread page passes that context to the upload detail API, which scopes the newer/older neighbors to that user's uploads. Arrow clicks reseed the context for the next thread, so the chain stays within the source list without a URL parameter. Threads opened directly (notification, reload) fall back to the global order. The breadcrumb reads the same context and shows the profile path for profile-originated threads, now including the thread id in the final crumb. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
export function useLastViewedUpload() {
|
|
return useState<string | null>('last-viewed-upload', () => null)
|
|
}
|
|
|
|
export interface PendingUploadMedia {
|
|
id: string
|
|
type: 'image' | 'video' | 'audio' | 'youtube' | 'twitch' | 'link'
|
|
url: string | null
|
|
thumbUrl: string | null
|
|
}
|
|
|
|
// Beim Tile-Klick schon bekannte Mediendaten, damit die Thread-Seite
|
|
// vor Eintreffen der API-Antwort ein benanntes Element für die
|
|
// View-Transition rendern kann
|
|
export function usePendingUploadMedia() {
|
|
return useState<PendingUploadMedia | null>('pending-upload-media', () => null)
|
|
}
|
|
|
|
export interface UploadNavContext {
|
|
uploadId: string
|
|
fromPath: string | null
|
|
fromLabel: string | null
|
|
}
|
|
|
|
// Herkunft der Thread-Navigation (z. B. /user/<id>): beim Tile-Klick gesetzt
|
|
// und von den Thread-Pfeilen für die Folgeseite weitergereicht. Gilt immer
|
|
// nur für die in uploadId hinterlegte Seite — ein direkt geöffneter Thread
|
|
// (Notification, Kommentar-Link, Reload) fällt auf die globale Reihenfolge
|
|
export function useUploadNavContext() {
|
|
return useState<UploadNavContext | null>('upload-nav-context', () => null)
|
|
}
|