modify the toast notification system to prevent spamming#293
Conversation
error notifications on the right side of the screen when the server is stopped.
|
Suppressed Duplicate Errors in ToastProvider |
rmyndharis
left a comment
There was a problem hiding this comment.
Thanks @quinton-8 — appreciate the focus on toast spam, and the happy path (success/warning/info and normal errors) is correctly left untouched. A few things to address before merge:
1. (Blocking) setTimeout is called inside the setToasts updater. State updater functions must be side-effect-free — under React 18 Strict Mode the updater runs twice (so two timers fire), and if an update is replayed/batched the timer can fire for a toast that was never committed, which can leave the dedup in a stuck state. Please mirror the existing addToast structure: compute the id first, do the dedup guard inside the updater (return prev when it's a duplicate), and call setTimeout(() => removeToast(id), 6000) after setToasts, not inside it. (This is the "side effects outside state updates" pattern in the repo's known-issues list.)
2. Extract the dedup sentinel. 'Server Connection Lost' is a hardcoded string used as the dedup key; if it's ever translated, the dedup silently breaks. Please pull it into a module-level constant (or an i18n key).
3. (Optional / follow-up) Scope. This only dedups a fixed list of network-error strings; other rapidly-repeating errors still stack. A more general fix would be a (type, title) dedup inside addToast itself — happy to take that as a separate follow-up if you'd prefer to keep this PR focused.
Items 1 and 2 are needed to merge; 3 is a nice-to-have. Thanks!
Modify the toast notification system to prevent spamming multiple error notifications on the right side of the screen when the server is
stopped.
Description
Brief description of changes
Type of Change
Checklist
Screenshots (if applicable)
Related Issues
Closes #