diff --git a/package.json b/package.json index cb216d00..79869eda 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "buildDev": "node esbuild.config.mjs dev", "lint": "eslint --cache --concurrency auto src", "lint:community": "eslint --config eslint.community.config.mjs --concurrency auto src", - "svelte-check": "svelte-check --tsconfig ./tsconfig.json", + "svelte-check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings", "tsc-check": "tsc --noEmit", "tsc-check:apps": "tsc --noEmit -p src/apps/browser/tsconfig.json && tsc --noEmit -p src/apps/cli/tsconfig.json && tsc --noEmit -p src/apps/webapp/tsconfig.json && tsc --noEmit -p src/apps/webpeer/tsconfig.app.json && tsc --noEmit -p src/apps/webpeer/tsconfig.node.json", "pretty:importpath": "cd utilsdeno && deno run -A ./normalise-imports.ts", diff --git a/src/features/P2PSync/P2PReplicator/P2POpenReplicationPane.svelte b/src/features/P2PSync/P2PReplicator/P2POpenReplicationPane.svelte index a6e6151c..395e93ae 100644 --- a/src/features/P2PSync/P2PReplicator/P2POpenReplicationPane.svelte +++ b/src/features/P2PSync/P2PReplicator/P2POpenReplicationPane.svelte @@ -27,7 +27,7 @@ let serverInfo = $state(undefined); let syncingPeerId = $state(null); - const logLevel = showResult ? LOG_LEVEL_NOTICE : LOG_LEVEL_INFO; + const logLevel = $derived(showResult ? LOG_LEVEL_NOTICE : LOG_LEVEL_INFO); async function requestServerStatus() { await liveSyncReplicator.requestStatus(); eventHub.emitEvent(EVENT_REQUEST_STATUS); diff --git a/src/features/P2PSync/P2PReplicator/P2PServerStatusCard.svelte b/src/features/P2PSync/P2PReplicator/P2PServerStatusCard.svelte index d85dd9d9..f007b7dc 100644 --- a/src/features/P2PSync/P2PReplicator/P2PServerStatusCard.svelte +++ b/src/features/P2PSync/P2PReplicator/P2PServerStatusCard.svelte @@ -23,8 +23,11 @@ let { liveSyncReplicator, showBroadcastToggle = true, core }: Props = $props(); let serverInfo = $state(undefined); let replicatorStatus = $state(undefined); - let roomSuffix = $state(extractP2PRoomSuffix(core?.services.setting.currentSettings()?.P2P_roomID ?? "")); - let useDiagRTC = $state(core?.services.setting.currentSettings()?.P2P_useDiagRTC ?? false); + // Later setting changes arrive through EVENT_SETTING_SAVED; these values only seed local state at mount time. + const readCurrentSettings = () => core?.services.setting.currentSettings(); + const initialSettings = readCurrentSettings(); + let roomSuffix = $state(extractP2PRoomSuffix(initialSettings?.P2P_roomID ?? "")); + let useDiagRTC = $state(initialSettings?.P2P_useDiagRTC ?? false); async function requestServerStatus() { await Promise.resolve(liveSyncReplicator.requestStatus()); @@ -307,4 +310,4 @@ font-size: 0.85rem; gap: 0.5rem; } - \ No newline at end of file + diff --git a/src/features/P2PSync/P2PReplicator/P2PServerStatusPane.svelte b/src/features/P2PSync/P2PReplicator/P2PServerStatusPane.svelte index af42fc80..308d777f 100644 --- a/src/features/P2PSync/P2PReplicator/P2PServerStatusPane.svelte +++ b/src/features/P2PSync/P2PReplicator/P2PServerStatusPane.svelte @@ -33,16 +33,17 @@ let replicatingPeerId = $state(null); let communicatingUntil = $state>({}); const COMMUNICATION_HOLD_MS = 2500; - let syncOnReplicationSetting = $state(core.services.setting.currentSettings()?.P2P_SyncOnReplication ?? ""); + // Later setting changes arrive through EVENT_SETTING_SAVED; these values only seed local state at mount time. + const readCurrentSettings = () => core.services.setting.currentSettings(); + const initialSettings = readCurrentSettings(); + let syncOnReplicationSetting = $state(initialSettings?.P2P_SyncOnReplication ?? ""); type P2PRemoteOption = { id: string; name: string; roomSuffix: string; }; let p2pRemoteOptions = $state([]); - let selectedP2PRemoteConfigurationId = $state( - core.services.setting.currentSettings()?.P2P_ActiveRemoteConfigurationId ?? "" - ); + let selectedP2PRemoteConfigurationId = $state(initialSettings?.P2P_ActiveRemoteConfigurationId ?? ""); let selectingP2PRemote = $state(false); function addToList(item: string, list: string): string { diff --git a/src/modules/services/LiveSyncUI/DialogHost.svelte b/src/modules/services/LiveSyncUI/DialogHost.svelte index 5c5483e2..a60d9318 100644 --- a/src/modules/services/LiveSyncUI/DialogHost.svelte +++ b/src/modules/services/LiveSyncUI/DialogHost.svelte @@ -12,33 +12,33 @@ // */ // onSetupContext?(props: DialogSvelteComponentBaseProps): void; // }; - const { setTitle, closeDialog, setResult, mountComponent, getInitialData, onSetupContext }: DialogHostProps = - $props(); + const props: DialogHostProps = $props(); const contextProps = { - setTitle, - closeDialog, - setResult, - getInitialData, - } satisfies DialogSvelteComponentBaseProps + setTitle: (title: string) => props.setTitle(title), + closeDialog: () => props.closeDialog(), + setResult: (result: any) => props.setResult(result), + getInitialData: () => props.getInitialData?.(), + } satisfies DialogSvelteComponentBaseProps; - // Call the onSetupContext function to setup the dialog context - onSetupContext?.(contextProps); + // Context must be established during component initialisation. The callbacks retain live access to the host props. + const setupContext = () => props.onSetupContext?.(contextProps); + setupContext(); /** * Wrapper around setResult to also close the dialog * @param result */ const setResultWrapper = (result: any) => { - setResult(result); - closeDialog(); + props.setResult(result); + props.closeDialog(); }; - const Component = mountComponent; + const Component = $derived(props.mountComponent); let thisElement: HTMLElement;
- +