From 7bdce37fd3f18e2712e18c4e2c64cac69af0aca1 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Sun, 19 Sep 2021 19:43:11 +0200 Subject: :boom: Introduce new UI based on svelte, and rewrite a lot of the node app and the NeoRuntime --- src_frontend/stores/notifs.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src_frontend/stores/notifs.js (limited to 'src_frontend/stores/notifs.js') diff --git a/src_frontend/stores/notifs.js b/src_frontend/stores/notifs.js new file mode 100644 index 0000000..f117f18 --- /dev/null +++ b/src_frontend/stores/notifs.js @@ -0,0 +1,24 @@ +import { writable } from "svelte/store"; +import { nanoid } from 'nanoid' + +export const notifs = writable([]); + +export function notif(notification) { + let _notif = { + id: nanoid(), + timeout: 10000, + ...notification + } + notifs.update(_notifs => { + setTimeout(() => { + removeNotif(_notif.id) + }, _notif.timeout); + return [..._notifs, _notif]; + }); +} + +export function removeNotif(notifId) { + notifs.update(_notifs => { + return _notifs.filter(n => n.id !== notifId); + }); +} -- cgit v1.2.3