Skip to content

Commit 16bc6e8

Browse files
outsourc-eAurora release bot
andauthored
fix(updates): show "Hermes updated" modal only once per release (#386)
The /api/update/status poll returns the same pendingReleaseNotes on every poll. Workspace was running storeNotes() inside a useEffect keyed on those notes, and storeNotes unconditionally cleared NOTES_SEEN_KEY. So every time the user refreshed the page (or a poll fired), the seen marker was dropped and the modal popped again. Now we only clear the seen marker when the notes ID has actually changed (i.e. a new release with different content). Identical payloads on refresh keep the seen marker intact. Closes #356 Co-authored-by: Aurora release bot <release@outsourc-e.com>
1 parent 2b8093b commit 16bc6e8

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/components/update-center-notifier.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,27 @@ function notesId(sections: Array<ReleaseNoteSection>): string {
8787

8888
function storeNotes(sections: Array<ReleaseNoteSection>): Notes | null {
8989
if (!sections.length) return null
90-
const notes = { id: notesId(sections), sections, updatedAt: Date.now() }
90+
const id = notesId(sections)
91+
const notes = { id, sections, updatedAt: Date.now() }
92+
// Only clear the "seen" marker when the release-notes payload actually
93+
// changed. Without this guard the modal pops up on every page refresh
94+
// because /api/update/status returns the same pendingReleaseNotes on every
95+
// poll, useEffect fires, and we used to drop the seen marker every time.
96+
// See #356.
97+
let existingId: string | null = null
98+
try {
99+
const raw = localStorage.getItem(NOTES_KEY)
100+
if (raw) {
101+
const parsed = JSON.parse(raw) as Notes
102+
existingId = parsed?.id ?? null
103+
}
104+
} catch {
105+
existingId = null
106+
}
107+
if (existingId !== id) {
108+
localStorage.removeItem(NOTES_SEEN_KEY)
109+
}
91110
localStorage.setItem(NOTES_KEY, JSON.stringify(notes))
92-
localStorage.removeItem(NOTES_SEEN_KEY)
93111
return notes
94112
}
95113

0 commit comments

Comments
 (0)