From 7a0f8e03bbbc353cf9a76f4f403438f5ca8b8b31 Mon Sep 17 00:00:00 2001 From: ltctceplrm <14954927+ltctceplrm@users.noreply.github.com> Date: Wed, 5 Mar 2025 17:24:50 +0100 Subject: [PATCH] Changed for.each loops to for loops --- src/settings/Settings.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/settings/Settings.ts b/src/settings/Settings.ts index 5d90080..1042802 100644 --- a/src/settings/Settings.ts +++ b/src/settings/Settings.ts @@ -331,22 +331,22 @@ export class MediaDbSettingTab extends PluginSettingTab { const mediaTypeApiMap = new Map(); // Populate the map with APIs for each media type - Object.entries(this.plugin.settings.apiToggle).forEach(([apiName, api]) => { - Object.entries(api).forEach(([mediaType]) => { + for (const [apiName, api] of Object.entries(this.plugin.settings.apiToggle)) { + for (const mediaType of Object.keys(api)) { if (!mediaTypeApiMap.has(mediaType)) { mediaTypeApiMap.set(mediaType, []); } mediaTypeApiMap.get(mediaType)!.push(apiName); - }); - }); + } + } // Filter out media types with only one API const filteredMediaTypes = Array.from(mediaTypeApiMap.entries()).filter(([_, apis]) => apis.length > 1); // Dynamically create settings based on the filtered media types and their APIs - filteredMediaTypes.forEach(([mediaType, apis]) => { + for (const [mediaType, apis] of filteredMediaTypes) { new Setting(containerEl).setName(`Select APIs for ${unCamelCase(mediaType)}`).setHeading(); - apis.forEach(apiName => { + for (const apiName of apis) { const apiToggle = this.plugin.settings.apiToggle[apiName as keyof typeof this.plugin.settings.apiToggle]; new Setting(containerEl) .setName(apiName) @@ -357,8 +357,8 @@ export class MediaDbSettingTab extends PluginSettingTab { void this.plugin.saveSettings(); }); }); - }); - }); + } + } new Setting(containerEl).setName('New file location').setHeading(); // region new file location