From 9c1dd8db6edb63f73dad328e8fe229cb22a0b145 Mon Sep 17 00:00:00 2001 From: shocknet-justin Date: Wed, 8 Oct 2025 19:42:34 -0400 Subject: [PATCH] try wizard state --- src/services/wizard/index.ts | 49 +++++++++++++++++++++++++----------- static/js/wizard.js | 10 ++++---- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/src/services/wizard/index.ts b/src/services/wizard/index.ts index 415c039f..9906d166 100644 --- a/src/services/wizard/index.ts +++ b/src/services/wizard/index.ts @@ -40,21 +40,40 @@ export class Wizard { } GetServiceState = async (): Promise => { - const apps = await this.storage.applicationStorage.GetApplications() - const appNamesList = apps.map(app => app.name).join(', ') - return { - admin_npub: this.adminManager.GetAdminNpub(), - http_url: this.settings.serviceUrl, - lnd_state: WizardTypes.LndState.OFFLINE, - nprofile: this.nprofile, - provider_name: appNamesList, - relay_connected: false, - relays: this.relays, - watchdog_ok: false, - source_name: this.settings.defaultAppName, - relay_url: this.settings.nostrRelaySettings.relays[0] || '', - automate_liquidity: this.settings.liquiditySettings.liquidityProviderPub !== 'null', - push_backups_to_nostr: this.settings.pushBackupsToNostr, + try { + const apps = await this.storage.applicationStorage.GetApplications() + const appNamesList = apps.map(app => app.name).join(', ') + return { + admin_npub: this.adminManager.GetAdminNpub(), + http_url: this.settings.serviceUrl, + lnd_state: WizardTypes.LndState.OFFLINE, + nprofile: this.nprofile, + provider_name: appNamesList, + relay_connected: false, + relays: this.relays, + watchdog_ok: false, + source_name: appNamesList || this.settings.defaultAppName, + relay_url: this.settings.nostrRelaySettings.relays[0] || '', + automate_liquidity: this.settings.liquiditySettings.liquidityProviderPub !== 'null', + push_backups_to_nostr: this.settings.pushBackupsToNostr, + } + } catch (e) { + this.log(`Error in GetServiceState: ${(e as Error).message}`) + // Return a default/error state that is still valid JSON to prevent client-side parse errors + return { + admin_npub: '', + http_url: '', + lnd_state: WizardTypes.LndState.OFFLINE, + nprofile: '', + provider_name: 'Error loading state', + relay_connected: false, + relays: [], + watchdog_ok: false, + source_name: 'Error', + relay_url: '', + automate_liquidity: false, + push_backups_to_nostr: false, + } } } WizardState = async (): Promise => { diff --git a/static/js/wizard.js b/static/js/wizard.js index 3c1d1732..bb73e1d1 100644 --- a/static/js/wizard.js +++ b/static/js/wizard.js @@ -122,21 +122,21 @@ $(() => { } else { // Pre-populate from service state fetch("/wizard/service-state").then(res => res.json()).then(state => { - nodeNameInput.val(state.sourceName); - if (state.relayUrl === 'wss://relay.lightning.pub') { + nodeNameInput.val(state.source_name); + if (state.relay_url === 'wss://relay.lightning.pub') { customCheckbox.prop('checked', true); } else { - relayUrlInput.val(state.relayUrl); + relayUrlInput.val(state.relay_url); } syncRelayState(); - if (state.automateLiquidity) { + if (state.automate_liquidity) { automateLiquidityRadio.prop('checked', true); } else { manualLiquidityRadio.prop('checked', true); } - if (state.pushBackupsToNostr) { + if (state.push_backups_to_nostr) { backupNostrRadio.prop('checked', true); } else { manualBackupRadio.prop('checked', true);