Skip to content

Commit

Permalink
fix(notify) simplify notification clear
Browse files Browse the repository at this point in the history
  • Loading branch information
lorumic committed May 31, 2023
1 parent 416dc86 commit 27a1f06
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/context/notify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ export const NotifyProvider: FC<NotifyProviderProps> = ({ children }) => {
const [notification, setNotification] = useState<Notification | null>(null);
const { state, pathname } = useLocation() as QueuedNotification;

const clear = () => notification !== null && setNotification(null);

useEffect(() => {
if (state?.queuedNotification) {
setDeduplicated(state.queuedNotification);
window.history.replaceState({}, "");
} else {
notification !== null && setNotification(null);
clear();
}
}, [state, pathname]);

Expand All @@ -95,7 +97,7 @@ export const NotifyProvider: FC<NotifyProviderProps> = ({ children }) => {

const helper: NotificationHelper = {
notification,
clear: () => notification !== null && setNotification(null),
clear,
queue,
failure: (title, error, message, actions) =>
setDeduplicated(failure(title, error, message, actions)),
Expand Down

0 comments on commit 27a1f06

Please sign in to comment.