From 4eb153bda7937dacef2402af95a514b5625fe28d Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Fri, 8 Nov 2019 16:27:56 +0400 Subject: [PATCH] Fix notifications reducer, fix provider notifications --- src/components/Notifier/index.js | 2 ++ src/logic/notifications/notificationBuilder.js | 1 - src/logic/notifications/store/models/notification.js | 2 +- src/logic/notifications/store/reducer/notifications.js | 5 ++--- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/Notifier/index.js b/src/components/Notifier/index.js index 136b1111..78143021 100644 --- a/src/components/Notifier/index.js +++ b/src/components/Notifier/index.js @@ -48,8 +48,10 @@ class Notifier extends Component { if (this.displayed.includes(notification.key)) { return } + // Display snackbar using notistack enqueueSnackbar(notification.message, { + key: notification.key, ...notification.options, onClose: (event, reason, key) => { if (notification.options.onClose) { diff --git a/src/logic/notifications/notificationBuilder.js b/src/logic/notifications/notificationBuilder.js index 1f237640..b1c46f30 100644 --- a/src/logic/notifications/notificationBuilder.js +++ b/src/logic/notifications/notificationBuilder.js @@ -153,7 +153,6 @@ export const enhanceSnackbarForAction = (notification: Notification) => ({ ...notification.options, action: (key) => ( store.dispatch(closeSnackbarAction(key))}> - {console.log(key, notification.message)} ), diff --git a/src/logic/notifications/store/models/notification.js b/src/logic/notifications/store/models/notification.js index 7452faa9..574925df 100644 --- a/src/logic/notifications/store/models/notification.js +++ b/src/logic/notifications/store/models/notification.js @@ -6,7 +6,7 @@ export type NotificationProps = { key?: number, message: string, options: Object, - dismissed: boolean, + dismissed?: boolean, } export const makeNotification: RecordFactory = Record({ diff --git a/src/logic/notifications/store/reducer/notifications.js b/src/logic/notifications/store/reducer/notifications.js index d16e0c0c..687f5ae8 100644 --- a/src/logic/notifications/store/reducer/notifications.js +++ b/src/logic/notifications/store/reducer/notifications.js @@ -18,10 +18,9 @@ export default handleActions( return state.set(notification.key, makeNotification(notification)) }, [CLOSE_SNACKBAR]: (state: NotificationReducerState, action: ActionType): NotificationReducerState => { - const { notification }: { notification: NotificationProps } = action.payload - notification.dismissed = true + const key = action.payload - return state.update(notification.key, (prev) => prev.merge(notification)) + return state.update(key, (prev) => prev.set('dismissed', true)) }, [REMOVE_SNACKBAR]: (state: NotificationReducerState, action: ActionType): NotificationReducerState => { const key = action.payload