mirror of
https://github.com/wassname/talk.git
synced 2026-06-30 06:14:52 +08:00
23 lines
600 B
JavaScript
23 lines
600 B
JavaScript
import * as actions from '../constants/notification';
|
|
|
|
export const notify = (kind, msg) => (dispatch, _, { notification }) => {
|
|
const messages = Array.isArray(msg) ? msg : [msg];
|
|
|
|
messages.forEach(message => {
|
|
switch (kind) {
|
|
case 'error':
|
|
notification.error(message);
|
|
break;
|
|
case 'info':
|
|
notification.info(message);
|
|
break;
|
|
case 'success':
|
|
notification.success(message);
|
|
break;
|
|
default:
|
|
throw new Error(`Unknown notification kind ${kind}`);
|
|
}
|
|
dispatch({ type: actions.NOTIFY, kind, message });
|
|
});
|
|
};
|