Fix notifications reducer, fix provider notifications
This commit is contained in:
parent
351b2c8592
commit
4eb153bda7
|
@ -48,8 +48,10 @@ class Notifier extends Component<Props> {
|
||||||
if (this.displayed.includes(notification.key)) {
|
if (this.displayed.includes(notification.key)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display snackbar using notistack
|
// Display snackbar using notistack
|
||||||
enqueueSnackbar(notification.message, {
|
enqueueSnackbar(notification.message, {
|
||||||
|
key: notification.key,
|
||||||
...notification.options,
|
...notification.options,
|
||||||
onClose: (event, reason, key) => {
|
onClose: (event, reason, key) => {
|
||||||
if (notification.options.onClose) {
|
if (notification.options.onClose) {
|
||||||
|
|
|
@ -153,7 +153,6 @@ export const enhanceSnackbarForAction = (notification: Notification) => ({
|
||||||
...notification.options,
|
...notification.options,
|
||||||
action: (key) => (
|
action: (key) => (
|
||||||
<IconButton onClick={() => store.dispatch(closeSnackbarAction(key))}>
|
<IconButton onClick={() => store.dispatch(closeSnackbarAction(key))}>
|
||||||
{console.log(key, notification.message)}
|
|
||||||
<IconClose />
|
<IconClose />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
),
|
),
|
||||||
|
|
|
@ -6,7 +6,7 @@ export type NotificationProps = {
|
||||||
key?: number,
|
key?: number,
|
||||||
message: string,
|
message: string,
|
||||||
options: Object,
|
options: Object,
|
||||||
dismissed: boolean,
|
dismissed?: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeNotification: RecordFactory<NotificationProps> = Record({
|
export const makeNotification: RecordFactory<NotificationProps> = Record({
|
||||||
|
|
|
@ -18,10 +18,9 @@ export default handleActions<NotificationReducerState, *>(
|
||||||
return state.set(notification.key, makeNotification(notification))
|
return state.set(notification.key, makeNotification(notification))
|
||||||
},
|
},
|
||||||
[CLOSE_SNACKBAR]: (state: NotificationReducerState, action: ActionType<Function>): NotificationReducerState => {
|
[CLOSE_SNACKBAR]: (state: NotificationReducerState, action: ActionType<Function>): NotificationReducerState => {
|
||||||
const { notification }: { notification: NotificationProps } = action.payload
|
const key = action.payload
|
||||||
notification.dismissed = true
|
|
||||||
|
|
||||||
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 => {
|
[REMOVE_SNACKBAR]: (state: NotificationReducerState, action: ActionType<Function>): NotificationReducerState => {
|
||||||
const key = action.payload
|
const key = action.payload
|
||||||
|
|
Loading…
Reference in New Issue