consumed easyadapter dialog and added timer
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
home: () => void;
|
||||
};
|
||||
|
||||
const EasyAdapterDialogProps = writable<EasyAdapterDialogPropsType>();
|
||||
export const EasyAdapterDialogProps = writable<EasyAdapterDialogPropsType>();
|
||||
type EasyAdapterDialogPropsType = {
|
||||
open: boolean;
|
||||
};
|
||||
|
||||
@@ -12,8 +12,27 @@
|
||||
scrimClickAction=""
|
||||
aria-labelledby="easy-adapter-dialog-title"
|
||||
aria-describedby="easy-adapter-dialog-content"
|
||||
class="easy-adapter-dialog"
|
||||
>
|
||||
<Title id="easy-adapter-dialog-title">Configuring Easy Adapter</Title>
|
||||
|
||||
<Content id="easy-adapter-dialog-content">This will take ~90 seconds to complete. Please wait until the process is complete.</Content>
|
||||
</Dialog>
|
||||
|
||||
<style>
|
||||
:global(.easy-adapter-dialog.mdc-dialog) {
|
||||
z-index: 10000 !important;
|
||||
}
|
||||
|
||||
:global(.easy-adapter-dialog .mdc-dialog__scrim) {
|
||||
z-index: 9999 !important;
|
||||
}
|
||||
|
||||
:global(.easy-adapter-dialog .mdc-dialog__container) {
|
||||
z-index: 10001 !important;
|
||||
}
|
||||
|
||||
:global(.easy-adapter-dialog .mdc-dialog__surface) {
|
||||
z-index: 10002 !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,12 +1,46 @@
|
||||
import { writable } from "svelte/store";
|
||||
import { showDialog, EasyAdapterDialogProps } from "$dialogs/DialogHost.svelte";
|
||||
|
||||
type DisplayUnits = "METRIC" | "IMPERIAL";
|
||||
|
||||
export const Config = writable<Record<string, any>>({});
|
||||
export const DisplayUnits = writable<DisplayUnits>();
|
||||
|
||||
let easyAdapterTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let hasShownEasyAdapter = false;
|
||||
|
||||
export function handleConfigUpdate(config: Record<string, any>) {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user