lint fix
This commit is contained in:
parent
92ad28a160
commit
a15e6b0e25
|
@ -3,28 +3,28 @@ import { writable } from "svelte/store"
|
||||||
const NOTIFICATION_TIMEOUT = 3000
|
const NOTIFICATION_TIMEOUT = 3000
|
||||||
|
|
||||||
const createNotificationStore = () => {
|
const createNotificationStore = () => {
|
||||||
const timeoutIds = new Set();
|
const timeoutIds = new Set()
|
||||||
const _notifications = writable([], () => {
|
const _notifications = writable([], () => {
|
||||||
return () => {
|
return () => {
|
||||||
// clear all the timers
|
// clear all the timers
|
||||||
timeoutIds.forEach(timeoutId => {
|
timeoutIds.forEach(timeoutId => {
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId)
|
||||||
});
|
})
|
||||||
_notifications.set([]);
|
_notifications.set([])
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
const send = (message, type = "default") => {
|
const send = (message, type = "default") => {
|
||||||
let _id = id();
|
let _id = id()
|
||||||
_notifications.update(state => {
|
_notifications.update(state => {
|
||||||
return [...state, { id: _id, type, message }]
|
return [...state, { id: _id, type, message }]
|
||||||
});
|
})
|
||||||
const timeoutId = setTimeout(() => {
|
const timeoutId = setTimeout(() => {
|
||||||
_notifications.update(state => {
|
_notifications.update(state => {
|
||||||
return state.filter(({ id }) => id !== _id);
|
return state.filter(({ id }) => id !== _id)
|
||||||
});
|
})
|
||||||
}, NOTIFICATION_TIMEOUT);
|
}, NOTIFICATION_TIMEOUT)
|
||||||
timeoutIds.add(timeoutId);
|
timeoutIds.add(timeoutId)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { subscribe } = _notifications
|
const { subscribe } = _notifications
|
||||||
|
@ -40,7 +40,12 @@ const createNotificationStore = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function id() {
|
function id() {
|
||||||
return '_' + Math.random().toString(36).substr(2, 9);
|
return (
|
||||||
};
|
"_" +
|
||||||
|
Math.random()
|
||||||
|
.toString(36)
|
||||||
|
.substr(2, 9)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export const notificationStore = createNotificationStore()
|
export const notificationStore = createNotificationStore()
|
|
@ -11,6 +11,6 @@ const transitions = new Map([
|
||||||
])
|
])
|
||||||
|
|
||||||
export default function transition(node, { type, options = {} }) {
|
export default function transition(node, { type, options = {} }) {
|
||||||
const { tn, opt } = transitions.get(type) || { tn: () => {}, opt: {}}
|
const { tn, opt } = transitions.get(type) || { tn: () => {}, opt: {} }
|
||||||
return tn(node, { ...opt, ...options })
|
return tn(node, { ...opt, ...options })
|
||||||
}
|
}
|
Loading…
Reference in New Issue