From 345d4a736616b3923c61c7b4b4f5065036bfd7be Mon Sep 17 00:00:00 2001 From: Xylight Date: Tue, 6 Aug 2024 17:11:47 -0700 Subject: [PATCH] perf: virtualize comment lists --- .../comment/CommentListVirtualizer.svelte | 52 +++++++++++++++++++ .../post/[instance]/[id=integer]/+page.svelte | 4 +- 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 src/lib/components/lemmy/comment/CommentListVirtualizer.svelte diff --git a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte new file mode 100644 index 00000000..8ec1a8ae --- /dev/null +++ b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte @@ -0,0 +1,52 @@ + + +
+
+ {#each items as row, index (row.index)} +
+ +
+ {/each} +
+
diff --git a/src/routes/post/[instance]/[id=integer]/+page.svelte b/src/routes/post/[instance]/[id=integer]/+page.svelte index e54ce3fe..02bbbf00 100644 --- a/src/routes/post/[instance]/[id=integer]/+page.svelte +++ b/src/routes/post/[instance]/[id=integer]/+page.svelte @@ -55,6 +55,7 @@ import { resumables } from '$lib/lemmy/item.js' import { contentPadding } from '$lib/components/ui/layout/Shell.svelte' import Placeholder from '$lib/components/ui/Placeholder.svelte' + import CommentListVirtualizer from '$lib/components/lemmy/comment/CommentListVirtualizer.svelte' export let data @@ -412,7 +413,7 @@ {/if} - {#if comments.comments.length == 0}