Changed for.each loops to for loops
This commit is contained in:
parent
4995727fd3
commit
7a0f8e03bb
1 changed files with 8 additions and 8 deletions
|
|
@ -331,22 +331,22 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
||||||
const mediaTypeApiMap = new Map<string, string[]>();
|
const mediaTypeApiMap = new Map<string, string[]>();
|
||||||
|
|
||||||
// Populate the map with APIs for each media type
|
// Populate the map with APIs for each media type
|
||||||
Object.entries(this.plugin.settings.apiToggle).forEach(([apiName, api]) => {
|
for (const [apiName, api] of Object.entries(this.plugin.settings.apiToggle)) {
|
||||||
Object.entries(api).forEach(([mediaType]) => {
|
for (const mediaType of Object.keys(api)) {
|
||||||
if (!mediaTypeApiMap.has(mediaType)) {
|
if (!mediaTypeApiMap.has(mediaType)) {
|
||||||
mediaTypeApiMap.set(mediaType, []);
|
mediaTypeApiMap.set(mediaType, []);
|
||||||
}
|
}
|
||||||
mediaTypeApiMap.get(mediaType)!.push(apiName);
|
mediaTypeApiMap.get(mediaType)!.push(apiName);
|
||||||
});
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
// Filter out media types with only one API
|
// Filter out media types with only one API
|
||||||
const filteredMediaTypes = Array.from(mediaTypeApiMap.entries()).filter(([_, apis]) => apis.length > 1);
|
const filteredMediaTypes = Array.from(mediaTypeApiMap.entries()).filter(([_, apis]) => apis.length > 1);
|
||||||
|
|
||||||
// Dynamically create settings based on the filtered media types and their APIs
|
// 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();
|
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];
|
const apiToggle = this.plugin.settings.apiToggle[apiName as keyof typeof this.plugin.settings.apiToggle];
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName(apiName)
|
.setName(apiName)
|
||||||
|
|
@ -357,8 +357,8 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
||||||
void this.plugin.saveSettings();
|
void this.plugin.saveSettings();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
new Setting(containerEl).setName('New file location').setHeading();
|
new Setting(containerEl).setName('New file location').setHeading();
|
||||||
// region new file location
|
// region new file location
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue