forked from BRETT/BRETT
Keep thread navigation within the originating upload list
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>
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
|
||||
const { t } = useI18n()
|
||||
const route = useRoute()
|
||||
const navContext = useUploadNavContext()
|
||||
|
||||
interface Crumb {
|
||||
label: string
|
||||
@@ -20,7 +21,20 @@ const crumbs = computed<Crumb[]>(() => {
|
||||
const list: Crumb[] = [{ label: t('palette.home'), to: '/' }]
|
||||
const p = route.path
|
||||
if (p === '/') return []
|
||||
if (p.startsWith('/t/')) list.push({ label: t('nav.thread') })
|
||||
if (p.startsWith('/t/')) {
|
||||
// Herkunft aus dem Nav-Kontext — wird von den Pfeilen weitergereicht.
|
||||
// Gilt nur für die hinterlegte Upload-ID (Tile-Klick oder Pfeil-Seed);
|
||||
// direkt geöffnete Threads (Notification, Reload) zeigen den schlichten
|
||||
// Crumb ohne Profilkette
|
||||
const ctx = navContext.value?.uploadId === route.params.id ? navContext.value : null
|
||||
if (ctx?.fromPath) {
|
||||
list.push(
|
||||
{ label: t('nav.users'), to: '/users' },
|
||||
{ label: ctx.fromLabel ?? t('nav.profile'), to: ctx.fromPath },
|
||||
)
|
||||
}
|
||||
list.push({ label: `${t('nav.thread')} ${route.params.id ?? ''}` })
|
||||
}
|
||||
else if (p === '/users') list.push({ label: t('nav.users') })
|
||||
else if (p.startsWith('/user/')) {
|
||||
list.push({ label: t('nav.users'), to: '/users' }, { label: t('nav.profile') })
|
||||
@@ -41,9 +55,10 @@ const crumbs = computed<Crumb[]>(() => {
|
||||
<BreadcrumbLink v-if="crumb.to" as-child>
|
||||
<NuxtLink :to="crumb.to">{{ crumb.label }}</NuxtLink>
|
||||
</BreadcrumbLink>
|
||||
<BreadcrumbPage v-else>
|
||||
<BreadcrumbPage v-else-if="i === crumbs.length - 1">
|
||||
{{ crumb.label }}
|
||||
</BreadcrumbPage>
|
||||
<span v-else>{{ crumb.label }}</span>
|
||||
</BreadcrumbItem>
|
||||
<BreadcrumbSeparator v-if="i < crumbs.length - 1" />
|
||||
</template>
|
||||
|
||||
@@ -37,8 +37,13 @@ const canPlaceholder = computed(() => {
|
||||
|
||||
const indicator = useLoadingIndicator()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const navigating = ref(false)
|
||||
|
||||
// Herkunft im State merken (kein URL-Param): /user/<id> scopt Thread-Pfeile
|
||||
// und Breadcrumbs auf die Uploads dieses Nutzers
|
||||
const navContext = useUploadNavContext()
|
||||
|
||||
const spanClass = computed(() => {
|
||||
if (uniform.value) return ''
|
||||
const count = props.upload.commentCount ?? 0
|
||||
@@ -81,6 +86,11 @@ async function openUpload(e: MouseEvent) {
|
||||
url: props.upload.url,
|
||||
thumbUrl: props.upload.thumbUrl ?? null,
|
||||
}
|
||||
navContext.value = {
|
||||
uploadId: props.upload.id,
|
||||
fromPath: /^\/user\/\d+$/.test(route.path) ? route.path : null,
|
||||
fromLabel: props.upload.userName ?? null,
|
||||
}
|
||||
|
||||
try {
|
||||
const threadFetch = $fetch(`/api/uploads/${props.upload.id}`)
|
||||
|
||||
Reference in New Issue
Block a user