diff --git a/src/lib/components/lemmy/comment/Comments.svelte b/src/lib/components/lemmy/comment/Comments.svelte index a1be2be8..4db232f9 100644 --- a/src/lib/components/lemmy/comment/Comments.svelte +++ b/src/lib/components/lemmy/comment/Comments.svelte @@ -16,6 +16,7 @@ import { toast } from 'mono-svelte' import { profile } from '$lib/auth.js' import { Button } from 'mono-svelte' + import { afterNavigate } from '$app/navigation' export let nodes: CommentNodeI[] export let isParent: boolean @@ -25,6 +26,8 @@ onMount(() => { hydrated = true + }) + afterNavigate(() => { if (isParent && $page.url.hash) { document.getElementById($page.url.hash)?.scrollIntoView({ behavior: 'smooth', diff --git a/src/routes/comment/[instance]/[id]/+page.ts b/src/routes/comment/[instance]/[id]/+page.ts index 29b69d62..5d49649b 100644 --- a/src/routes/comment/[instance]/[id]/+page.ts +++ b/src/routes/comment/[instance]/[id]/+page.ts @@ -10,6 +10,6 @@ export async function load({ params, fetch }) { redirect( 302, - `/post/${params.instance}/${comment.comment_view.post.id}?thread=${comment.comment_view.comment.path}#${comment.comment_view.comment.id}` - ); + `/post/${params.instance}/${comment.comment_view.post.id}?thread=${comment.comment_view.comment.path}#${comment.comment_view.comment.id}` + ); } diff --git a/src/routes/post/[instance]/[id=integer]/+page.svelte b/src/routes/post/[instance]/[id=integer]/+page.svelte index fdd82896..cdd86779 100644 --- a/src/routes/post/[instance]/[id=integer]/+page.svelte +++ b/src/routes/post/[instance]/[id=integer]/+page.svelte @@ -119,7 +119,7 @@ max_depth: data.post.post_view.counts.comments > 100 ? 1 : 3, }) loading = false - data.singleThread = false + data.thread.singleThread = false commentsPage = 1 } @@ -235,7 +235,27 @@ {/if} -{#if data.singleThread} +{#if data.thread.showContext} + + + + You're viewing part of a thread. + + + Show Context + + +{:else if data.thread.singleThread} = 9) { + const sliced = split.slice(0, split.length - 4) + showContext = sliced[sliced.length - 1] + parentId = Number(split[split.length - 5]) + } else { + parentId = Number(split[1]) + } if (!Number.isInteger(parentId)) { parentId = undefined @@ -42,10 +50,13 @@ export async function load({ params, url, fetch }) { } return { - singleThread: parentId != undefined, + thread: { + showContext: showContext, + singleThread: parentId != undefined + }, post: post, commentSort: sort, - comments: await getClient(params.instance, fetch).getComments(commentParams), + comments: await getClient(params.instance, fetch).getComments(commentParams), slots: { sidebar: { component: CommunityCard,
+ + You're viewing part of a thread. +