Fix notifications reducer, fix provider notifications

This commit is contained in:
Mikhail Mikheev 2019-11-08 16:27:56 +04:00
parent 351b2c8592
commit 4eb153bda7
4 changed files with 5 additions and 5 deletions

View File

@ -48,8 +48,10 @@ class Notifier extends Component<Props> {
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) {

View File

@ -153,7 +153,6 @@ export const enhanceSnackbarForAction = (notification: Notification) => ({
...notification.options,
action: (key) => (
<IconButton onClick={() => store.dispatch(closeSnackbarAction(key))}>
{console.log(key, notification.message)}
<IconClose />
</IconButton>
),

View File

@ -6,7 +6,7 @@ export type NotificationProps = {
key?: number,
message: string,
options: Object,
dismissed: boolean,
dismissed?: boolean,
}
export const makeNotification: RecordFactory<NotificationProps> = Record({

View File

@ -18,10 +18,9 @@ export default handleActions<NotificationReducerState, *>(
return state.set(notification.key, makeNotification(notification))
},
[CLOSE_SNACKBAR]: (state: NotificationReducerState, action: ActionType<Function>): 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<Function>): NotificationReducerState => {
const key = action.payload