|
|
|
@ -20,7 +20,16 @@ export const createNotificationStore = () => { |
|
|
|
setTimeout(() => (block = false), timeout) |
|
|
|
} |
|
|
|
|
|
|
|
const send = (message, type = "default", icon = "", autoDismiss = true) => { |
|
|
|
const send = ( |
|
|
|
message, |
|
|
|
{ |
|
|
|
type = "default", |
|
|
|
icon = "", |
|
|
|
autoDismiss = true, |
|
|
|
action = null, |
|
|
|
wide = false, |
|
|
|
} |
|
|
|
) => { |
|
|
|
if (block) { |
|
|
|
return |
|
|
|
} |
|
|
|
@ -28,7 +37,15 @@ export const createNotificationStore = () => { |
|
|
|
_notifications.update(state => { |
|
|
|
return [ |
|
|
|
...state, |
|
|
|
{ id: _id, type, message, icon, dismissable: !autoDismiss }, |
|
|
|
{ |
|
|
|
id: _id, |
|
|
|
type, |
|
|
|
message, |
|
|
|
icon, |
|
|
|
dismissable: !autoDismiss, |
|
|
|
action, |
|
|
|
wide, |
|
|
|
}, |
|
|
|
] |
|
|
|
}) |
|
|
|
if (autoDismiss) { |
|
|
|
@ -50,10 +67,11 @@ export const createNotificationStore = () => { |
|
|
|
return { |
|
|
|
subscribe, |
|
|
|
send, |
|
|
|
info: msg => send(msg, "info", "Info"), |
|
|
|
error: msg => send(msg, "error", "Alert", false), |
|
|
|
warning: msg => send(msg, "warning", "Alert"), |
|
|
|
success: msg => send(msg, "success", "CheckmarkCircle"), |
|
|
|
info: msg => send(msg, { type: "info", icon: "Info" }), |
|
|
|
error: msg => |
|
|
|
send(msg, { type: "error", icon: "Alert", autoDismiss: false }), |
|
|
|
warning: msg => send(msg, { type: "warning", icon: "Alert" }), |
|
|
|
success: msg => send(msg, { type: "success", icon: "CheckmarkCircle" }), |
|
|
|
blockNotifications, |
|
|
|
dismiss: dismissNotification, |
|
|
|
} |
|
|
|
|