fix: add show context for long threads, close #215
This commit is contained in:
1 parent
2e4bfd8912
commit
a548ab145c
4 files changed
+41
-7
No files matched your search
@@ -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 @@
|
||||
</Expandable>
|
||||
{/if}
|
||||
</div>
|
||||
{#if data.singleThread}
|
||||
{#if data.thread.showContext}
|
||||
<Material
|
||||
elevation="max"
|
||||
padding="none"
|
||||
color="distinct"
|
||||
class="py-2 px-4 text-sm flex flex-row justify-between items-center
|
||||
flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
|
||||
>
|
||||
<p class="font-medium text-sm flex items-center gap-2">
|
||||
<Icon src={InformationCircle} mini size="20" />
|
||||
You're viewing part of a thread.
|
||||
</p>
|
||||
<Button
|
||||
{loading}
|
||||
disabled={loading}
|
||||
href="/comment/{$page.params.instance}/{data.thread.showContext}"
|
||||
>
|
||||
Show Context
|
||||
</Button>
|
||||
</Material>
|
||||
{:else if data.thread.singleThread}
|
||||
<Material
|
||||
elevation="max"
|
||||
padding="none"
|
||||
|
||||
@@ -15,9 +15,17 @@ export async function load({ params, url, fetch }) {
|
||||
|
||||
const thread = url.searchParams.get('thread')
|
||||
let parentId: number | undefined
|
||||
let showContext: string | undefined = undefined
|
||||
|
||||
if (thread) {
|
||||
parentId = Number(thread.split('.')[1])
|
||||
const split = thread.split('.')
|
||||
if (split.length >= 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,
|
||||
|
||||
Reference in new issue
Block a user