diff --git a/src/app/main/index.ts b/src/app/main/index.ts index 0813c9f..20fbb87 100644 --- a/src/app/main/index.ts +++ b/src/app/main/index.ts @@ -194,6 +194,13 @@ export async function init() { app.setAppUserModelId('uk.org.fancy.nxapi.app'); } + import('../../common/remote-config.js').then(m => { + if (!m.default.status_update_url) return; + appinstance.statusupdates.addSource(m.default.status_update_url); + }).catch(err => { + debug('error adding status update source from remote config', err); + }); + appinstance.statusupdates.subscribe({ onUpdate: data => sendToAllWindows('nxapi:statusupdates', data), }); diff --git a/src/cli/util/status.ts b/src/cli/util/status.ts index 408f360..b50ed1d 100644 --- a/src/cli/util/status.ts +++ b/src/cli/util/status.ts @@ -12,6 +12,10 @@ export function builder(yargs: Argv) { return yargs.option('url', { describe: 'Additional status update source', type: 'array', + }).option('use-config', { + describe: 'Use the status update source from nxapi\'s remote configuration', + type: 'boolean', + default: true, }).option('json', { describe: 'Output raw JSON', type: 'boolean', @@ -24,10 +28,13 @@ export function builder(yargs: Argv) { type Arguments = YargsArguments>; export async function handler(argv: ArgumentsCamelCase) { - // const { default: config } = await import('../../common/remote-config.js'); - const status = new StatusUpdateMonitor(); + if (argv.useConfig) { + const { default: config } = await import('../../common/remote-config.js'); + if (config.status_update_url) status.addSource(config.status_update_url); + } + for (const url of argv.url ?? []) { status.addSource(url.toString()); } diff --git a/src/common/remote-config.ts b/src/common/remote-config.ts index fb5bea0..c715ed0 100644 --- a/src/common/remote-config.ts +++ b/src/common/remote-config.ts @@ -251,6 +251,7 @@ export interface NxapiRemoteConfig { */ require_version: string[]; + status_update_url?: string; log_encryption_key?: string; // If null the API should not be used