Remove timeoutIds
This commit is contained in:
parent
b0a714de28
commit
fc0bffda60
|
@ -4,17 +4,9 @@ import { routeStore } from "./routes"
|
||||||
const NOTIFICATION_TIMEOUT = 3000
|
const NOTIFICATION_TIMEOUT = 3000
|
||||||
|
|
||||||
const createNotificationStore = () => {
|
const createNotificationStore = () => {
|
||||||
const timeoutIds = new Set()
|
|
||||||
let block = false
|
let block = false
|
||||||
|
|
||||||
const store = writable([], () => {
|
const store = writable([])
|
||||||
return () => {
|
|
||||||
timeoutIds.forEach(timeoutId => {
|
|
||||||
clearTimeout(timeoutId)
|
|
||||||
})
|
|
||||||
store.set([])
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const blockNotifications = (timeout = 1000) => {
|
const blockNotifications = (timeout = 1000) => {
|
||||||
block = true
|
block = true
|
||||||
|
@ -54,10 +46,9 @@ const createNotificationStore = () => {
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
if (autoDismiss) {
|
if (autoDismiss) {
|
||||||
const timeoutId = setTimeout(() => {
|
setTimeout(() => {
|
||||||
dismiss(_id)
|
dismiss(_id)
|
||||||
}, NOTIFICATION_TIMEOUT)
|
}, NOTIFICATION_TIMEOUT)
|
||||||
timeoutIds.add(timeoutId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue