From ab3edafc70d466f5bd45c4b837d5143f94714d98 Mon Sep 17 00:00:00 2001 From: Anton Franzluebbers Date: Thu, 2 Nov 2023 16:48:39 -0400 Subject: [PATCH] store currentDeviceId in localstorage --- velconnect-svelte-npm/package.json | 4 ++-- velconnect-svelte-npm/src/index.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/velconnect-svelte-npm/package.json b/velconnect-svelte-npm/package.json index 81d8484..ad50620 100644 --- a/velconnect-svelte-npm/package.json +++ b/velconnect-svelte-npm/package.json @@ -1,6 +1,6 @@ { "name": "@velaboratory/velconnect-svelte", - "version": "1.0.4", + "version": "1.0.5", "description": "Use VEL-Connect with a Svelte dashboard", "main": "src/index.js", "files": [ @@ -20,4 +20,4 @@ "devDependencies": { "typescript": "^5.1.6" } -} +} \ No newline at end of file diff --git a/velconnect-svelte-npm/src/index.ts b/velconnect-svelte-npm/src/index.ts index 19c5660..fdab94c 100644 --- a/velconnect-svelte-npm/src/index.ts +++ b/velconnect-svelte-npm/src/index.ts @@ -21,7 +21,9 @@ pb.authStore.onChange((auth) => { }); export const pairedDevices = writable([]); -export const currentDeviceId = writable(""); +const storedCurrentDeviceId = localStorage.getItem('currentDeviceId'); +export const currentDeviceId = writable(storedCurrentDeviceId || ""); +currentDeviceId.subscribe((value) => localStorage.setItem('currentDeviceId', value)); export interface Device extends Record { os_info: string; @@ -331,4 +333,4 @@ function log(msg: string) { if (debugLog) { console.log(msg); } -} +} \ No newline at end of file