lint fixes
This commit is contained in:
parent
21e46285f7
commit
f45726a047
|
@ -1,5 +1,11 @@
|
||||||
import * as API from "./api"
|
import * as API from "./api"
|
||||||
import { authStore, notificationStore, routeStore, screenStore, bindingStore } from "./store"
|
import {
|
||||||
|
authStore,
|
||||||
|
notificationStore,
|
||||||
|
routeStore,
|
||||||
|
screenStore,
|
||||||
|
bindingStore,
|
||||||
|
} from "./store"
|
||||||
import { styleable } from "./utils/styleable"
|
import { styleable } from "./utils/styleable"
|
||||||
import { linkable } from "./utils/linkable"
|
import { linkable } from "./utils/linkable"
|
||||||
import DataProvider from "./components/DataProvider.svelte"
|
import DataProvider from "./components/DataProvider.svelte"
|
||||||
|
|
|
@ -1,21 +1,17 @@
|
||||||
import { writable, derived } from "svelte/store"
|
import { writable, derived } from "svelte/store"
|
||||||
import { generate } from "shortid"
|
import { generate } from "shortid"
|
||||||
|
|
||||||
|
|
||||||
let NOTIFICATION_TIMEOUT = 3000
|
let NOTIFICATION_TIMEOUT = 3000
|
||||||
|
|
||||||
const createNotificationStore = () => {
|
const createNotificationStore = () => {
|
||||||
const _notifications = writable([])
|
const _notifications = writable([])
|
||||||
|
|
||||||
const send = (message, type = "default") => {
|
const send = (message, type = "default") => {
|
||||||
_notifications.update(state => {
|
_notifications.update(state => {
|
||||||
return [
|
return [...state, { id: generate(), type, message }]
|
||||||
...state,
|
|
||||||
{ id: generate(), type, message },
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const notifications = derived(_notifications, ($_notifications, set) => {
|
const notifications = derived(_notifications, ($_notifications, set) => {
|
||||||
set($_notifications)
|
set($_notifications)
|
||||||
if ($_notifications.length > 0) {
|
if ($_notifications.length > 0) {
|
||||||
|
@ -27,20 +23,20 @@ const createNotificationStore = () => {
|
||||||
set($_notifications)
|
set($_notifications)
|
||||||
}, NOTIFICATION_TIMEOUT)
|
}, NOTIFICATION_TIMEOUT)
|
||||||
return () => {
|
return () => {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout)
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const { subscribe } = notifications
|
const { subscribe } = notifications
|
||||||
|
|
||||||
return {
|
return {
|
||||||
subscribe,
|
subscribe,
|
||||||
send,
|
send,
|
||||||
danger: msg => send(msg, "danger"),
|
danger: msg => send(msg, "danger"),
|
||||||
warning: msg => send(msg, "warning"),
|
warning: msg => send(msg, "warning"),
|
||||||
info: msg => send(msg, "info"),
|
info: msg => send(msg, "info"),
|
||||||
success: msg => send(msg, "success"),
|
success: msg => send(msg, "success"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const notificationStore = createNotificationStore()
|
export const notificationStore = createNotificationStore()
|
||||||
|
|
Loading…
Reference in New Issue