Skip to content

Commit

Permalink
Fixed advanced search by adding a default media type for certain APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
ltctceplrm committed Jan 31, 2024
1 parent d1affcd commit 508b0ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/modals/MediaDbAdvancedSearchModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,23 @@ export class MediaDbAdvancedSearchModal extends Modal {

// const apiToggleComponents: Component[] = [];
for (const api of this.plugin.apiManager.apis) {
const apiToggleListElementWrapper = contentEl.createEl('div', { cls: 'media-db-plugin-list-wrapper' });
if (this.plugin.settings[[api.apiName, "default"].filter(s => s).join('') as keyof typeof this.plugin.settings] || this.plugin.settings[[api.apiName, "game"].filter(s => s).join('') as keyof typeof this.plugin.settings] || this.plugin.settings[[api.apiName, "series"].filter(s => s).join('') as keyof typeof this.plugin.settings] || this.plugin.settings[[api.apiName, "movie"].filter(s => s).join('') as keyof typeof this.plugin.settings]) {
const apiToggleListElementWrapper = contentEl.createEl('div', { cls: 'media-db-plugin-list-wrapper' });

const apiToggleTextWrapper = apiToggleListElementWrapper.createEl('div', { cls: 'media-db-plugin-list-text-wrapper' });
apiToggleTextWrapper.createEl('span', { text: api.apiName, cls: 'media-db-plugin-list-text' });
apiToggleTextWrapper.createEl('small', { text: api.apiDescription, cls: 'media-db-plugin-list-text' });
const apiToggleTextWrapper = apiToggleListElementWrapper.createEl('div', { cls: 'media-db-plugin-list-text-wrapper' });
apiToggleTextWrapper.createEl('span', { text: api.apiName, cls: 'media-db-plugin-list-text' });
apiToggleTextWrapper.createEl('small', { text: api.apiDescription, cls: 'media-db-plugin-list-text' });

const apiToggleComponentWrapper = apiToggleListElementWrapper.createEl('div', { cls: 'media-db-plugin-list-toggle' });
const apiToggleComponentWrapper = apiToggleListElementWrapper.createEl('div', { cls: 'media-db-plugin-list-toggle' });

const apiToggleComponent = new ToggleComponent(apiToggleComponentWrapper);
apiToggleComponent.setTooltip(api.apiName);
apiToggleComponent.setValue(this.selectedApis.find(x => x.name === api.apiName).selected);
apiToggleComponent.onChange(value => {
this.selectedApis.find(x => x.name === api.apiName).selected = value;
});
apiToggleComponentWrapper.appendChild(apiToggleComponent.toggleEl);
const apiToggleComponent = new ToggleComponent(apiToggleComponentWrapper);
apiToggleComponent.setTooltip(api.apiName);
apiToggleComponent.setValue(this.selectedApis.find(x => x.name === api.apiName).selected);
apiToggleComponent.onChange(value => {
this.selectedApis.find(x => x.name === api.apiName).selected = value;
});
apiToggleComponentWrapper.appendChild(apiToggleComponent.toggleEl);
}
}

contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
Expand Down
10 changes: 10 additions & 0 deletions src/settings/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export interface MediaDbPluginSettings {
MALAPIseries: boolean;
SteamAPIgame: boolean;
MobyGamesAPIgame: boolean;
BoardGameGeekAPIdefault: boolean;
MALAPIMangadefault: boolean;
MusicBrainzAPIdefault: boolean;
OpenLibraryAPIdefault: boolean;
WikipediaAPIdefault: boolean;

movieTemplate: string;
seriesTemplate: string;
Expand Down Expand Up @@ -83,6 +88,11 @@ const DEFAULT_SETTINGS: MediaDbPluginSettings = {
MALAPImovie: true,
SteamAPIgame: true,
MobyGamesAPIgame: true,
BoardGameGeekAPIdefault: true,
MALAPIMangadefault: true,
MusicBrainzAPIdefault: true,
OpenLibraryAPIdefault: true,
WikipediaAPIdefault: true,

movieTemplate: '',
seriesTemplate: '',
Expand Down

0 comments on commit 508b0ed

Please sign in to comment.