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
|
<Button
|
||||||
color="secondary"
|
color="secondary"
|
||||||
href="/post/{comment.post.id}#{comment.comment.id}"
|
href="/post/{comment.post.id}?thread={comment.comment.path}#{comment
|
||||||
|
.comment.id}"
|
||||||
size="sm"
|
size="sm"
|
||||||
class="self-start"
|
class="self-start"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -85,7 +85,11 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</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>
|
||||||
<div>
|
<div>
|
||||||
<Comment
|
<Comment
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
let moreComments = true
|
let moreComments = true
|
||||||
|
|
||||||
async function reloadComments() {
|
async function reloadComments() {
|
||||||
|
data.singleThread = false
|
||||||
commentsPage = 1
|
commentsPage = 1
|
||||||
|
|
||||||
data.streamed.comments = getClient().getComments({
|
data.streamed.comments = getClient().getComments({
|
||||||
@@ -171,6 +172,12 @@
|
|||||||
bind:selected={commentSort}
|
bind:selected={commentSort}
|
||||||
on:select={reloadComments}
|
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}
|
{#await data.streamed.comments}
|
||||||
<div class="h-16 mx-auto grid place-items-center">
|
<div class="h-16 mx-auto grid place-items-center">
|
||||||
<Spinner width={24} />
|
<Spinner width={24} />
|
||||||
@@ -198,6 +205,7 @@
|
|||||||
<Button
|
<Button
|
||||||
{loading}
|
{loading}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
|
color="tertiary"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
if (!moreComments) return
|
if (!moreComments) return
|
||||||
loading = true
|
loading = true
|
||||||
|
|||||||
@@ -7,7 +7,25 @@ export async function load({ params, url }) {
|
|||||||
auth: get(authData)?.token,
|
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 {
|
return {
|
||||||
|
singleThread: parentId != undefined,
|
||||||
post: post,
|
post: post,
|
||||||
streamed: {
|
streamed: {
|
||||||
comments: getClient(params.instance.toLowerCase()).getComments({
|
comments: getClient(params.instance.toLowerCase()).getComments({
|
||||||
@@ -15,10 +33,11 @@ export async function load({ params, url }) {
|
|||||||
type_: 'All',
|
type_: 'All',
|
||||||
limit: 25,
|
limit: 25,
|
||||||
page: 1,
|
page: 1,
|
||||||
max_depth: post.post_view.counts.comments > 100 ? 1 : 3,
|
max_depth: max_depth,
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
sort: 'Hot',
|
sort: 'Hot',
|
||||||
auth: get(authData)?.token,
|
auth: get(authData)?.token,
|
||||||
|
parent_id: parentId,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user