Skip to content

Commit 845b639

Browse files
committed
fix(notifications): clears notification state on logout, removes orphaned toasts on dismiss
1 parent 4bd510c commit 845b639

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/app/components/shared/ToastContainer.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ export default function ToastContainer() {
160160
for (const source of lastToastedAt.keys()) {
161161
if (!currentSources.has(source)) lastToastedAt.delete(source);
162162
}
163+
// Remove visible toasts whose notifications were dismissed from the store
164+
for (const id of visibleToasts().keys()) {
165+
if (!currentIds.has(id)) {
166+
const t = timeouts.get(id);
167+
if (t !== undefined) { clearTimeout(t); timeouts.delete(id); }
168+
const dt = dismissingTimeouts.get(id);
169+
if (dt !== undefined) { clearTimeout(dt); dismissingTimeouts.delete(id); }
170+
removeToast(id);
171+
}
172+
}
163173
});
164174

165175
onCleanup(() => {

src/app/services/poll.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
resetEmptyActionRepos,
1414
} from "./api";
1515
import { detectNewItems, dispatchNotifications, _resetNotificationState } from "../lib/notifications";
16-
import { pushError, pushNotification, getNotifications, dismissNotificationBySource, startCycleTracking, endCycleTracking } from "../lib/errors";
16+
import { pushError, pushNotification, getNotifications, dismissNotificationBySource, startCycleTracking, endCycleTracking, clearNotifications } from "../lib/errors";
17+
import { mutedSources } from "../components/shared/ToastContainer";
1718

1819
// ── Types ────────────────────────────────────────────────────────────────────
1920

@@ -44,6 +45,8 @@ function resetPollState(): void {
4445
_notifGateDisabled = false;
4546
_resetNotificationState();
4647
resetEmptyActionRepos();
48+
clearNotifications();
49+
mutedSources.clear();
4750
}
4851

4952
// Auto-reset poll state on logout (avoids circular dep with auth.ts)

0 commit comments

Comments
 (0)