From 74d6b306b9bacce853c96639c2e49d5342cddbd2 Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Tue, 6 May 2025 09:27:54 -0500 Subject: [PATCH] Track loaded addresses in a publication --- src/lib/components/Publication.svelte | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib/components/Publication.svelte b/src/lib/components/Publication.svelte index 968ad2a..ffb2f28 100644 --- a/src/lib/components/Publication.svelte +++ b/src/lib/components/Publication.svelte @@ -30,6 +30,7 @@ // TODO: Test load handling. let leaves = $state([]); + let loadedAddresses = $state>(new Set()); let isLoading = $state(false); let lastElementRef = $state(null); @@ -40,10 +41,21 @@ for (let i = 0; i < count; i++) { const nextItem = await publicationTree.next(); + + const nextAddress = nextItem.value?.tagAddress(); + if (nextAddress && loadedAddresses.has(nextAddress)) { + continue; + } + + if (nextAddress && !loadedAddresses.has(nextAddress)) { + loadedAddresses.add(nextAddress); + } + if (leaves.includes(nextItem.value) || (nextItem.done && nextItem.value === null)) { isLoading = false; return; } + leaves.push(nextItem.value); }