feat: add better thread viewing
This commit is contained in:
1 parent
e1f84441f0
commit
461a15a1ef
4 files changed
+35
-3
No files matched your search
@@ -21,7 +21,8 @@
|
||||
/>
|
||||
<Button
|
||||
color="secondary"
|
||||
href="/post/{comment.post.id}#{comment.comment.id}"
|
||||
href="/post/{comment.post.id}?thread={comment.comment.path}#{comment
|
||||
.comment.id}"
|
||||
size="sm"
|
||||
class="self-start"
|
||||
>
|
||||
|
||||
@@ -85,7 +85,11 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<Button href="/post/{item.post.id}#{item.comment.id}">Jump</Button>
|
||||
<Button
|
||||
href="/post/{item.post.id}?thread={item.comment.path}#{item.comment.id}"
|
||||
>
|
||||
Jump
|
||||
</Button>
|
||||
</div>
|
||||
<div>
|
||||
<Comment
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
let moreComments = true
|
||||
|
||||
async function reloadComments() {
|
||||
data.singleThread = false
|
||||
commentsPage = 1
|
||||
|
||||
data.streamed.comments = getClient().getComments({
|
||||
@@ -171,6 +172,12 @@
|
||||
bind:selected={commentSort}
|
||||
on:select={reloadComments}
|
||||
/>
|
||||
{#if data.singleThread}
|
||||
<Card class="py-2 px-4 text-sm flex flex-row items-center flex-wrap gap-4">
|
||||
<p>You're viewing a single thread.</p>
|
||||
<Button on:click={reloadComments}>View full thread</Button>
|
||||
</Card>
|
||||
{/if}
|
||||
{#await data.streamed.comments}
|
||||
<div class="h-16 mx-auto grid place-items-center">
|
||||
<Spinner width={24} />
|
||||
@@ -198,6 +205,7 @@
|
||||
<Button
|
||||
{loading}
|
||||
disabled={loading}
|
||||
color="tertiary"
|
||||
on:click={async () => {
|
||||
if (!moreComments) return
|
||||
loading = true
|
||||
|
||||
@@ -7,7 +7,25 @@ export async function load({ params, url }) {
|
||||
auth: get(authData)?.token,
|
||||
})
|
||||
|
||||
let max_depth = post.post_view.counts.comments > 100 ? 1 : 3
|
||||
|
||||
const thread = url.searchParams.get('thread')
|
||||
let parentId: number | undefined
|
||||
|
||||
if (thread) {
|
||||
parentId = Number(thread.split('.')[1])
|
||||
|
||||
if (!Number.isInteger(parentId)) {
|
||||
parentId = undefined
|
||||
}
|
||||
}
|
||||
|
||||
if (parentId) {
|
||||
max_depth = 10
|
||||
}
|
||||
|
||||
return {
|
||||
singleThread: parentId != undefined,
|
||||
post: post,
|
||||
streamed: {
|
||||
comments: getClient(params.instance.toLowerCase()).getComments({
|
||||
@@ -15,10 +33,11 @@ export async function load({ params, url }) {
|
||||
type_: 'All',
|
||||
limit: 25,
|
||||
page: 1,
|
||||
max_depth: post.post_view.counts.comments > 100 ? 1 : 3,
|
||||
max_depth: max_depth,
|
||||
saved_only: false,
|
||||
sort: 'Hot',
|
||||
auth: get(authData)?.token,
|
||||
parent_id: parentId,
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user