From 0f37863c0699cbf19116fe3dafde5f72d1b4052a Mon Sep 17 00:00:00 2001 From: CWX Date: Thu, 8 Aug 2024 18:25:11 +0100 Subject: [PATCH] fix types being returned --- project/src/callbacks/Launcherv2Callbacks.ts | 4 +- .../src/controllers/LauncherV2Controller.ts | 42 +++++++------------ .../spt/callbacks/ILauncherV2Callbacks.ts | 4 +- 3 files changed, 18 insertions(+), 32 deletions(-) diff --git a/project/src/callbacks/Launcherv2Callbacks.ts b/project/src/callbacks/Launcherv2Callbacks.ts index 4e6a8b31..ecb5dc44 100644 --- a/project/src/callbacks/Launcherv2Callbacks.ts +++ b/project/src/callbacks/Launcherv2Callbacks.ts @@ -88,11 +88,11 @@ export class LauncherV2Callbacks { }) } - public profile(): Error { + public profile(): any { throw new Error("Method not implemented."); } - public profileMods(): Error { + public profileMods(): any { throw new Error("Method not implemented."); } } \ No newline at end of file diff --git a/project/src/controllers/LauncherV2Controller.ts b/project/src/controllers/LauncherV2Controller.ts index 015a4e57..55f4494f 100644 --- a/project/src/controllers/LauncherV2Controller.ts +++ b/project/src/controllers/LauncherV2Controller.ts @@ -52,37 +52,23 @@ export class LauncherV2Controller { */ public types(): Record { - const profileRecord: Record = {}; - - // Get all possible profile types, excluding blacklisted ones - const profileKeys = Object.keys(this.databaseService.getProfiles()).filter( - (key) => !this.coreConfig.features.createNewProfileTypesBlacklist.includes(key), - ); - - // Add them to record with description - for (const profileKey in profileKeys) { - profileRecord[profileKey] = this.getProfileDescription(profileKey); - } - - return profileRecord; - } - - /** - * Returns a string that represents the Profile types description. - * - This is also localised. - * - * @param key Profile Type Name: eg "standard" - * @returns Profile Type Description - */ - protected getProfileDescription(key: string): string { + const result = {}; const dbProfiles = this.databaseService.getProfiles(); - const descKey = dbProfiles[key]?.descriptionLocaleKey; - if (!descKey) { - this.logger.warning(this.localisationService.getText("launcher-missing_property", key)); - return ""; + for (const profileKey in dbProfiles) { + if (this.coreConfig.features.createNewProfileTypesBlacklist.includes(profileKey)) { + continue; + } + + const localeKey = dbProfiles[profileKey]?.descriptionLocaleKey; + if (!localeKey) { + this.logger.warning(this.localisationService.getText("launcher-missing_property", profileKey)); + continue; + } + + result[profileKey] = this.localisationService.getText(localeKey); } - return this.localisationService.getText(key); + return result; } /** diff --git a/project/src/models/spt/callbacks/ILauncherV2Callbacks.ts b/project/src/models/spt/callbacks/ILauncherV2Callbacks.ts index f743fdcf..63ee71b2 100644 --- a/project/src/models/spt/callbacks/ILauncherV2Callbacks.ts +++ b/project/src/models/spt/callbacks/ILauncherV2Callbacks.ts @@ -20,6 +20,6 @@ export interface ILauncherV2Callbacks { compatibleVersion(): ILauncherV2VersionResponse; mods(): ILauncherV2ModsResponse; profiles(): ILauncherV2ProfilesResponse; - profile(): Error - profileMods(): Error + profile(): any + profileMods(): any } \ No newline at end of file