Merge: stop stale toasts resurrecting on reload
This commit is contained in:
commit
13df08a61e
1 changed files with 5 additions and 1 deletions
|
|
@ -118,7 +118,11 @@ function load(): Notification[] {
|
||||||
try {
|
try {
|
||||||
const raw = JSON.parse(localStorage.getItem(HISTORY_KEY) || "[]");
|
const raw = JSON.parse(localStorage.getItem(HISTORY_KEY) || "[]");
|
||||||
if (!Array.isArray(raw)) return [];
|
if (!Array.isArray(raw)) return [];
|
||||||
return raw.map((n) => ({ ...n, action: undefined }) as Notification);
|
// Restored entries are history only. Mark them dismissed so they don't
|
||||||
|
// resurrect as active toasts on reload — their auto-dismiss timers aren't
|
||||||
|
// re-armed across a reload, so otherwise they'd stick forever. Also drop the
|
||||||
|
// live `action` callback, which can't survive serialization.
|
||||||
|
return raw.map((n) => ({ ...n, action: undefined, dismissed: true }) as Notification);
|
||||||
} catch {
|
} catch {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue