Update auto dismissal of notifications
This commit is contained in:
parent
dd07f3516f
commit
fe495345f8
|
@ -20,15 +20,18 @@ export const createNotificationStore = () => {
|
||||||
setTimeout(() => (block = false), timeout)
|
setTimeout(() => (block = false), timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
const send = (message, type = "default", icon = "", timeout = true) => {
|
const send = (message, type = "default", icon = "", autoDismiss = true) => {
|
||||||
if (block) {
|
if (block) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let _id = id()
|
let _id = id()
|
||||||
_notifications.update(state => {
|
_notifications.update(state => {
|
||||||
return [...state, { id: _id, type, message, icon, dismissable: !timeout }]
|
return [
|
||||||
|
...state,
|
||||||
|
{ id: _id, type, message, icon, dismissable: !autoDismiss },
|
||||||
|
]
|
||||||
})
|
})
|
||||||
if (timeout) {
|
if (autoDismiss) {
|
||||||
const timeoutId = setTimeout(() => {
|
const timeoutId = setTimeout(() => {
|
||||||
dismissNotification(_id)
|
dismissNotification(_id)
|
||||||
}, NOTIFICATION_TIMEOUT)
|
}, NOTIFICATION_TIMEOUT)
|
||||||
|
|
Loading…
Reference in New Issue