FloodActions: do not fetchNotifications after clearNotifications

This avoids race between state changes. Server should be trusted
and assumed to have done the job.
This commit is contained in:
Jesse Chan
2020-11-10 19:37:49 +08:00
parent c21af9ab37
commit 00504393f6
2 changed files with 3 additions and 7 deletions
@@ -72,14 +72,14 @@ const ServerEventHandlers: Record<keyof ServerEvents, (event: unknown) => void>
} as const;
const FloodActions = {
clearNotifications: (options: NotificationFetchOptions) => {
clearNotifications: () => {
NotificationStore.clearAll();
return axios
.delete(`${baseURI}api/notifications`)
.then((json) => json.data)
.then(
() => {
FloodActions.fetchNotifications(options);
// do nothing.
},
() => {
// do nothing.
@@ -222,11 +222,7 @@ class NotificationsButton extends Component<WrappedComponentProps, Notifications
this.tooltipRef.dismissTooltip();
}
FloodActions.clearNotifications({
id: 'notification-tooltip',
limit: NOTIFICATIONS_PER_PAGE,
start: 0,
});
FloodActions.clearNotifications();
};
handleNotificationCountChange = () => {