From e1324921e9b599c108e46ff92fc3e35e879688a6 Mon Sep 17 00:00:00 2001 From: FoxxMD Date: Mon, 3 Aug 2026 15:38:35 +0000 Subject: [PATCH] fix: Fix missing name passed to component classes --- src/backend/scrobblers/ScrobbleClients.ts | 17 +++++++++-------- src/backend/sources/ScrobbleSources.ts | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/backend/scrobblers/ScrobbleClients.ts b/src/backend/scrobblers/ScrobbleClients.ts index ae4d1580..b8c250b5 100644 --- a/src/backend/scrobblers/ScrobbleClients.ts +++ b/src/backend/scrobblers/ScrobbleClients.ts @@ -224,6 +224,7 @@ export default class ScrobbleClients { const parsed = entry.source === 'file' ? (await validateClientJson(entry.type, entry.config)) : (await validateClientAIOJson(entry.type, entry.config)); parsedConfig = { ...parsed, + name: parsed.name ?? parsed.id, source: generateConfigLocation('client', entry) } } break; @@ -285,42 +286,42 @@ export default class ScrobbleClients { case 'discord': { const DiscordScrobbler = (await import('./DiscordScrobbler.ts')).default; await this.instantiateClients('discord', strongConfigs, clientDefaults, DiscordScrobbler, - (config, options) => [config.name, { ...config, options }, {}, this.emitter, this.logger]); + (config, options) => [config.name ?? config.id, { ...config, options }, {}, this.emitter, this.logger]); } break; case 'koito': { const KoitoScrobbler = (await import('./KoitoScrobbler.ts')).default; await this.instantiateClients('koito', strongConfigs, clientDefaults, KoitoScrobbler, - (config, options) => [config.name, { ...config, options: { ...options, configDir: this.internalConfig.configDir } }, {}, this.emitter, this.logger]); + (config, options) => [config.name ?? config.id, { ...config, options: { ...options, configDir: this.internalConfig.configDir } }, {}, this.emitter, this.logger]); } break; case 'lastfm': { const LastfmScrobbler = (await import('./LastfmScrobbler.ts')).default; await this.instantiateClients('lastfm', strongConfigs, clientDefaults, LastfmScrobbler, - (config, options) => [config.name, { ...config, options }, this.internalConfig, this.emitter, this.logger]); + (config, options) => [config.name ?? config.id, { ...config, options }, this.internalConfig, this.emitter, this.logger]); } break; case 'librefm': { const LibrefmScrobbler = (await import('./LibrefmScrobbler.ts')).default; await this.instantiateClients('librefm', strongConfigs, clientDefaults, LibrefmScrobbler, - (config, options) => [config.name, { ...config, options }, this.internalConfig, this.emitter, this.logger]); + (config, options) => [config.name ?? config.id, { ...config, options }, this.internalConfig, this.emitter, this.logger]); } break; case 'listenbrainz': { const ListenbrainzScrobbler = (await import('./ListenbrainzScrobbler.ts')).default; await this.instantiateClients('listenbrainz', strongConfigs, clientDefaults, ListenbrainzScrobbler, - (config, options) => [config.name, { ...config, options }, this.internalConfig, this.emitter, this.logger]); + (config, options) => [config.name ?? config.id, { ...config, options }, this.internalConfig, this.emitter, this.logger]); } break; case 'maloja': { const MalojaScrobbler = (await import('./MalojaScrobbler.ts')).default; await this.instantiateClients('maloja', strongConfigs, clientDefaults, MalojaScrobbler, - (config, options) => [config.name, { ...config, options }, this.emitter, this.logger]); + (config, options) => [config.name ?? config.id, { ...config, options }, this.emitter, this.logger]); } break; case 'rocksky': { const RockskyScrobbler = (await import('./RockskyScrobbler.ts')).default; await this.instantiateClients('rocksky', strongConfigs, clientDefaults, RockskyScrobbler, - (config, options) => [config.name, { ...config, options }, this.internalConfig, this.emitter, this.logger]); + (config, options) => [config.name ?? config.id, { ...config, options }, this.internalConfig, this.emitter, this.logger]); } break; case 'tealfm': { const TealScrobbler = (await import('./TealfmScrobbler.ts')).default; await this.instantiateClients('tealfm', strongConfigs, clientDefaults, TealScrobbler, - (config, options) => [config.name, { ...config, options }, this.internalConfig, this.emitter, this.logger]); + (config, options) => [config.name ?? config.id, { ...config, options }, this.internalConfig, this.emitter, this.logger]); } break; } } diff --git a/src/backend/sources/ScrobbleSources.ts b/src/backend/sources/ScrobbleSources.ts index 18c575a2..4a4cc352 100644 --- a/src/backend/sources/ScrobbleSources.ts +++ b/src/backend/sources/ScrobbleSources.ts @@ -247,6 +247,7 @@ export default class ScrobbleSources { const parsed = entry.source === 'file' ? (await validateSourceJson(entry.type, entry.config)) : (await validateSourceAIOJson(entry.type, entry.config)); parsedConfig = { ...parsed, + name: parsed.name ?? parsed.id, source: generateConfigLocation('source', entry) } } break; @@ -293,7 +294,7 @@ export default class ScrobbleSources { try { const config = await validateSourceJson(sourceType, s); const compositeOptions = { ...defaults, ...config.options }; - const newComponent = new Ctor(config.name, { ...config, options: compositeOptions }, this.internalConfig, this.emitter); + const newComponent = new Ctor(config.name ?? config.id, { ...config, options: compositeOptions }, this.internalConfig, this.emitter); newComponent.logger.info(`Source added from ${s.source}`); this.sources.push(newComponent); } catch (e) { -- 2.51.2