diff --git a/src/svelte-components/src/dialogs/DialogHost.svelte b/src/svelte-components/src/dialogs/DialogHost.svelte index 86850ab..ad5336b 100644 --- a/src/svelte-components/src/dialogs/DialogHost.svelte +++ b/src/svelte-components/src/dialogs/DialogHost.svelte @@ -19,7 +19,7 @@ home: () => void; }; - const EasyAdapterDialogProps = writable(); + export const EasyAdapterDialogProps = writable(); type EasyAdapterDialogPropsType = { open: boolean; }; diff --git a/src/svelte-components/src/dialogs/EasyAdapterDialog.svelte b/src/svelte-components/src/dialogs/EasyAdapterDialog.svelte index 78c4780..0169240 100644 --- a/src/svelte-components/src/dialogs/EasyAdapterDialog.svelte +++ b/src/svelte-components/src/dialogs/EasyAdapterDialog.svelte @@ -12,8 +12,27 @@ scrimClickAction="" aria-labelledby="easy-adapter-dialog-title" aria-describedby="easy-adapter-dialog-content" + class="easy-adapter-dialog" > Configuring Easy Adapter This will take ~90 seconds to complete. Please wait until the process is complete. + + diff --git a/src/svelte-components/src/lib/ConfigStore.ts b/src/svelte-components/src/lib/ConfigStore.ts index 19a2f8c..eddc3b0 100644 --- a/src/svelte-components/src/lib/ConfigStore.ts +++ b/src/svelte-components/src/lib/ConfigStore.ts @@ -1,12 +1,46 @@ import { writable } from "svelte/store"; +import { showDialog, EasyAdapterDialogProps } from "$dialogs/DialogHost.svelte"; type DisplayUnits = "METRIC" | "IMPERIAL"; export const Config = writable>({}); export const DisplayUnits = writable(); +let easyAdapterTimer: ReturnType | null = null; +let hasShownEasyAdapter = false; + export function handleConfigUpdate(config: Record) { Config.set(config); + + // Check if easy-adapter is enabled and show dialog on app load + if (config.settings && config.settings["easy-adapter"] && !hasShownEasyAdapter) { + hasShownEasyAdapter = true; + + try { + // Clear any existing timer first + if (easyAdapterTimer) { + clearTimeout(easyAdapterTimer); + easyAdapterTimer = null; + } + + // Show EasyAdapter dialog + showDialog("EasyAdapter", {}); + + // Auto-close after 90 seconds + easyAdapterTimer = setTimeout(() => { + try { + EasyAdapterDialogProps.set({ open: false }); + } catch (error) { + console.error("Failed to close EasyAdapter dialog:", error); + } finally { + easyAdapterTimer = null; + } + }, 90000); + } catch (error) { + console.error("Failed to show EasyAdapter dialog:", error); + hasShownEasyAdapter = false; // Reset on error + } + } } export function setDisplayUnits(value: DisplayUnits) {