Reverse reply sort order, move more replies button to top of replies

This commit is contained in:
Jonathan Staab 2022-12-27 15:55:02 -08:00
parent fb3426e80e
commit 3d095e83ef
2 changed files with 10 additions and 9 deletions

View File

@ -182,14 +182,15 @@
{/if}
{#if depth > 0}
{#each note.replies as r (r.id)}
<div class="ml-5 border-l border-solid border-medium">
{#if note.repliesCount > 3 && note.replies.length < note.repliesCount}
<div class="ml-5 py-2 text-light cursor-pointer" on:click={onClick}>
<i class="fa-solid fa-up-down text-sm pr-2" />
Show {quantify(note.repliesCount - note.replies.length, 'other reply', 'more replies')}
</div>
{/if}
{#each note.replies as r (r.id)}
<svelte:self showParent={false} note={r} depth={depth - 1} {invertColors} {anchorId} />
</div>
{/each}
{#if note.repliesCount > 5 && note.replies.length < note.repliesCount}
<div class="ml-10 mt-2 text-light cursor-pointer" on:click={onClick}>
{quantify(note.repliesCount - note.replies.length, 'more reply', 'more replies')} found.
{/each}
</div>
{/if}
{/if}

View File

@ -102,8 +102,8 @@ const findNote = async (id, {showEntire = false, depth = 1} = {}) => {
replies: depth === 0
? []
: await Promise.all(
sortBy(e => -e.created_at, replies)
.slice(0, showEntire ? Infinity : 3)
sortBy(e => e.created_at, replies)
.slice(showEntire ? 0 : -3)
.map(r => findNote(r.id, {depth: depth - 1}))
),
}