fix(frontend): dedupe identical banners in banner.ts
Multiple independent requests that fail with the same message (e.g. Activities.tsx's mount effect firing loadFirstPage/listWorkoutKinds/getProfile separately) each call showError() independently, previously stacking 2-3 textually-identical banners for a single root cause (backend down, brief network blip). show() now skips adding a banner if one with the same severity+message is already visible, and skips scheduling a redundant auto-dismiss timer for it -- the original banner's timer keeps running untouched.
This commit is contained in:
@@ -17,6 +17,11 @@ function notify() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function show(severity: BannerSeverity, message: string): void {
|
function show(severity: BannerSeverity, message: string): void {
|
||||||
|
const isDuplicate = banners.some(
|
||||||
|
(b) => b.severity === severity && b.message === message,
|
||||||
|
);
|
||||||
|
if (isDuplicate) return;
|
||||||
|
|
||||||
const id = nextId++;
|
const id = nextId++;
|
||||||
banners = [{ id, severity, message }, ...banners];
|
banners = [{ id, severity, message }, ...banners];
|
||||||
notify();
|
notify();
|
||||||
|
|||||||
Reference in New Issue
Block a user