nandi/gleanpublic Fork 0
51a47fb
Commits
Clone
git clone https://git.rickub.com/nandi/glean.git
git clone ssh://git@rickub.com/nandi/glean.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

fix: fix stale unread articles after disgest marked as readUnverified

Julien Robert committed 2026-07-03T09:03:57+02:00 Browse files
51a47fb parent: 0f3f03a
modified web/src/routes/dashboard/+page.svelte +8 -2
@@ -23,6 +23,11 @@
2323 let followed = $state<PersonRecommendation[]>([]);
2424 let discover = $state<PersonRecommendation[]>([]);
2525 let digest = $state<Digest | null>(null);
26+ let locallyRead = $state<Set<number>>(new Set());
27+
28+ const unreadArticles = $derived(
29+ data.articles.filter((a) => !locallyRead.has(a.id)),
30+ );
2631
2732 $effect(() => {
2833 if (data.subscription_count > 0) {
@@ -67,6 +72,7 @@
6772 if (!confirm("Mark these articles as read?")) return;
6873 await endpoints.markDigestRead(digest.article_ids);
6974 digest = { ...digest, consumed: true };
75+ locallyRead = new Set(digest.article_ids);
7076 }
7177
7278 const trending: TrendingItem[] = $derived([
@@ -116,7 +122,7 @@
116122 >
117123 </div>
118124 </div>
119-{:else if data.articles.length > 0}
125+ :else if unreadArticles.length > 0
120126 <!-- Recommended articles -->
121127 {#if articleRecs && articleRecs.length > 0}
122128 <section class="mb-10">
@@ -211,7 +217,7 @@
211217 >
212218 </div>
213219 <div class="space-y-3">
214- {#each data.articles as a (a.id)}
220+ {#each unreadArticles as a (a.id)}
215221 <ArticleCard article={a} />
216222 {/each}
217223 </div>
@@ -23,6 +23,11 @@
23 let followed = $state<PersonRecommendation[]>([]);23 let followed = $state<PersonRecommendation[]>([]);
24 let discover = $state<PersonRecommendation[]>([]);24 let discover = $state<PersonRecommendation[]>([]);
25 let digest = $state<Digest | null>(null);25 let digest = $state<Digest | null>(null);
26+ let locallyRead = $state<Set<number>>(new Set());
27+
28+ const unreadArticles = $derived(
29+ data.articles.filter((a) => !locallyRead.has(a.id)),
30+ );
26 31
27 $effect(() => {32 $effect(() => {
28 if (data.subscription_count > 0) {33 if (data.subscription_count > 0) {
@@ -67,6 +72,7 @@
67 if (!confirm("Mark these articles as read?")) return;72 if (!confirm("Mark these articles as read?")) return;
68 await endpoints.markDigestRead(digest.article_ids);73 await endpoints.markDigestRead(digest.article_ids);
69 digest = { ...digest, consumed: true };74 digest = { ...digest, consumed: true };
75+ locallyRead = new Set(digest.article_ids);
70 }76 }
71 77
72 const trending: TrendingItem[] = $derived([78 const trending: TrendingItem[] = $derived([
@@ -116,7 +122,7 @@
116 >122 >
117 </div>123 </div>
118 </div>124 </div>
119-{:else if data.articles.length > 0}125+ :else if unreadArticles.length > 0
120 <!-- Recommended articles -->126 <!-- Recommended articles -->
121 {#if articleRecs && articleRecs.length > 0}127 {#if articleRecs && articleRecs.length > 0}
122 <section class="mb-10">128 <section class="mb-10">
@@ -211,7 +217,7 @@
211 >217 >
212 </div>218 </div>
213 <div class="space-y-3">219 <div class="space-y-3">
214- {#each data.articles as a (a.id)}220+ {#each unreadArticles as a (a.id)}
215 <ArticleCard article={a} />221 <ArticleCard article={a} />
216 {/each}222 {/each}
217 </div>223 </div>