nandi/gleanpublic Fork 0
fbad959
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(web): fix auto mark as readUnverified

Julien Robert committed 2026-08-03T12:48:57+02:00 Browse files
fbad959 parent: 54e50b3
modified web/src/routes/articles/[id]/+page.svelte +7 -6
@@ -58,17 +58,18 @@
5858 annotations = data.annotations;
5959 });
6060
61- // Sync local optimistic state when navigating between articles.
62- $effect(() => {
63- read = data.article.is_read;
64- });
61+ // Tracks which article id we've already auto-marked read, so the effect
62+ // fires once per navigation instead of fighting toggleRead's updates.
63+ let markedReadId = $state<number | null>(null);
6564
6665 // Mark the article read on actual navigation. The server's detail handler
6766 // no longer marks read, so a hover/touch preload won't mark every hovered
68- // card as read; only a real visit does.
67+ // card as read; only a real visit does. Runs once per article, so
68+ // toggleRead stays in control of subsequent state changes.
6969 $effect(() => {
7070 const id = data.article.id;
71- if (!read) {
71+ if (markedReadId !== id) {
72+ markedReadId = id;
7273 read = true;
7374 endpoints.markRead(id).catch(() => {
7475 if (data.article.id === id) read = false;
@@ -58,17 +58,18 @@
58 annotations = data.annotations;58 annotations = data.annotations;
59 });59 });
60 60
61- // Sync local optimistic state when navigating between articles.61+ // Tracks which article id we've already auto-marked read, so the effect
62- $effect(() => {62+ // fires once per navigation instead of fighting toggleRead's updates.
63- read = data.article.is_read;63+ let markedReadId = $state<number | null>(null);
64- });
65 64
66 // Mark the article read on actual navigation. The server's detail handler65 // Mark the article read on actual navigation. The server's detail handler
67 // no longer marks read, so a hover/touch preload won't mark every hovered66 // no longer marks read, so a hover/touch preload won't mark every hovered
68- // card as read; only a real visit does.67+ // card as read; only a real visit does. Runs once per article, so
68+ // toggleRead stays in control of subsequent state changes.
69 $effect(() => {69 $effect(() => {
70 const id = data.article.id;70 const id = data.article.id;
71- if (!read) {71+ if (markedReadId !== id) {
72+ markedReadId = id;
72 read = true;73 read = true;
73 endpoints.markRead(id).catch(() => {74 endpoints.markRead(id).catch(() => {
74 if (data.article.id === id) read = false;75 if (data.article.id === id) read = false;