aboutsummaryrefslogtreecommitdiff
path: root/src_frontend/stores/notifs.js
diff options
context:
space:
mode:
authorJakob Stendahl <jakob.stendahl@outlook.com>2021-09-19 19:43:11 +0200
committerJakob Stendahl <jakob.stendahl@outlook.com>2021-09-19 19:43:11 +0200
commit7bdce37fd3f18e2712e18c4e2c64cac69af0aca1 (patch)
treeb7ad3f1cca92e2dfd2664ae9e65652bd03ff58b2 /src_frontend/stores/notifs.js
parente6880cd8ccf82d993f222cb14b4860581654acb8 (diff)
downloadLuxcena-Neo-7bdce37fd3f18e2712e18c4e2c64cac69af0aca1.tar.gz
Luxcena-Neo-7bdce37fd3f18e2712e18c4e2c64cac69af0aca1.zip
:boom: Introduce new UI based on svelte, and rewrite a lot of the node app and the NeoRuntime
Diffstat (limited to 'src_frontend/stores/notifs.js')
-rw-r--r--src_frontend/stores/notifs.js24
1 files changed, 24 insertions, 0 deletions
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);
+ });
+}