Ran formatter, removed unused array and updated APIModel.ts
This commit is contained in:
parent
f52060482a
commit
5eec98d127
8 changed files with 44 additions and 45 deletions
|
|
@ -18,7 +18,7 @@ export class APIManager {
|
|||
console.debug(`MDB | api manager queried with "${query}"`);
|
||||
|
||||
let res: MediaTypeModel[] = [];
|
||||
|
||||
|
||||
for (const api of this.apis) {
|
||||
if (apisToQuery.contains(api.apiName)) {
|
||||
const apiRes = await api.searchByTitle(query);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { MediaTypeModel } from '../models/MediaTypeModel';
|
||||
import { MediaType } from '../utils/MediaType';
|
||||
import { MediaDbPluginSettings } from 'src/settings/Settings';
|
||||
import MediaDbPlugin from '../main';
|
||||
|
||||
export abstract class APIModel {
|
||||
|
|
@ -19,7 +20,7 @@ export abstract class APIModel {
|
|||
abstract getById(id: string): Promise<MediaTypeModel>;
|
||||
|
||||
hasType(type: MediaType): boolean {
|
||||
if (this.types.contains(type) && !(this.plugin.settings[[this.apiName, type].filter(s => s).join('') as keyof typeof this.plugin.settings] === false)){
|
||||
if (this.types.contains(type) && !(this.plugin.settings[(this.apiName + type) as keyof MediaDbPluginSettings] === false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -32,4 +33,4 @@ export abstract class APIModel {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -671,4 +671,4 @@ export default class MediaDbPlugin extends Plugin {
|
|||
|
||||
await this.saveData(this.settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,20 +89,20 @@ export class MediaDbAdvancedSearchModal extends Modal {
|
|||
for (const api of this.plugin.apiManager.apis) {
|
||||
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' });
|
||||
|
||||
|
|
|
|||
|
|
@ -76,9 +76,8 @@ export class MediaDbSearchModal extends Modal {
|
|||
|
||||
const placeholder = 'Search by title';
|
||||
const searchComponent = new TextComponent(contentEl);
|
||||
const toggleComponents = [];
|
||||
let currentToggle: ToggleComponent = null;
|
||||
|
||||
|
||||
searchComponent.inputEl.style.width = '100%';
|
||||
searchComponent.setPlaceholder(placeholder);
|
||||
searchComponent.setValue(this.query);
|
||||
|
|
@ -119,7 +118,6 @@ export class MediaDbSearchModal extends Modal {
|
|||
}
|
||||
});
|
||||
apiToggleComponentWrapper.appendChild(apiToggleComponent.toggleEl);
|
||||
toggleComponents.push(apiToggleComponent);
|
||||
}
|
||||
|
||||
contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
|
||||
|
|
@ -146,4 +144,4 @@ export class MediaDbSearchModal extends Modal {
|
|||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
new Setting(containerEl)
|
||||
.setName('Moby Games key')
|
||||
.setDesc('API key for "www.mobygames.com".')
|
||||
.addText(cb => {
|
||||
|
|
@ -223,10 +223,10 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
.setDesc(
|
||||
fragWithHTML(
|
||||
"Your custom date format. Use <em>'YYYY-MM-DD'</em> for example.<br>" +
|
||||
"For more syntax, refer to <a href='https://momentjs.com/docs/#/displaying/format/'>format reference</a>.<br>" +
|
||||
"Your current syntax looks like this: <b><a id='media-db-dateformat-preview' style='pointer-events: none; cursor: default; text-decoration: none;'>" +
|
||||
this.plugin.dateFormatter.getPreview() +
|
||||
'</a></b>',
|
||||
"For more syntax, refer to <a href='https://momentjs.com/docs/#/displaying/format/'>format reference</a>.<br>" +
|
||||
"Your current syntax looks like this: <b><a id='media-db-dateformat-preview' style='pointer-events: none; cursor: default; text-decoration: none;'>" +
|
||||
this.plugin.dateFormatter.getPreview() +
|
||||
'</a></b>',
|
||||
),
|
||||
)
|
||||
.addText(cb => {
|
||||
|
|
@ -278,23 +278,23 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
containerEl.createEl('h3', { text: 'APIs Per Media Type' });
|
||||
containerEl.createEl('h5', { text: 'Movies' });
|
||||
new Setting(containerEl)
|
||||
.setName('OMDb API')
|
||||
.setDesc('Use OMDb API for movies.')
|
||||
.addToggle(cb => {
|
||||
cb.setValue(this.plugin.settings.OMDbAPImovie).onChange(data => {
|
||||
this.plugin.settings.OMDbAPImovie = data;
|
||||
this.plugin.saveSettings();
|
||||
.setName('OMDb API')
|
||||
.setDesc('Use OMDb API for movies.')
|
||||
.addToggle(cb => {
|
||||
cb.setValue(this.plugin.settings.OMDbAPImovie).onChange(data => {
|
||||
this.plugin.settings.OMDbAPImovie = data;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
});
|
||||
new Setting(containerEl)
|
||||
.setName('MAL API')
|
||||
.setDesc('Use MAL API for movies.')
|
||||
.addToggle(cb => {
|
||||
cb.setValue(this.plugin.settings.MALAPImovie).onChange(data => {
|
||||
this.plugin.settings.MALAPImovie = data;
|
||||
this.plugin.saveSettings();
|
||||
.setName('MAL API')
|
||||
.setDesc('Use MAL API for movies.')
|
||||
.addToggle(cb => {
|
||||
cb.setValue(this.plugin.settings.MALAPImovie).onChange(data => {
|
||||
this.plugin.settings.MALAPImovie = data;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
});
|
||||
containerEl.createEl('h5', { text: 'Series' });
|
||||
new Setting(containerEl)
|
||||
.setName('OMDb API')
|
||||
|
|
@ -305,7 +305,7 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
new Setting(containerEl)
|
||||
new Setting(containerEl)
|
||||
.setName('MAL API')
|
||||
.setDesc('Use MAL API for series.')
|
||||
.addToggle(cb => {
|
||||
|
|
@ -315,7 +315,7 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
});
|
||||
});
|
||||
containerEl.createEl('h5', { text: 'Games' });
|
||||
new Setting(containerEl)
|
||||
new Setting(containerEl)
|
||||
.setName('OMDb API')
|
||||
.setDesc('Use OMDb API for games.')
|
||||
.addToggle(cb => {
|
||||
|
|
@ -324,7 +324,7 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
new Setting(containerEl)
|
||||
new Setting(containerEl)
|
||||
.setName('Steam API')
|
||||
.setDesc('Use OMDb API for games.')
|
||||
.addToggle(cb => {
|
||||
|
|
@ -333,7 +333,7 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
new Setting(containerEl)
|
||||
new Setting(containerEl)
|
||||
.setName('MobyGames API')
|
||||
.setDesc('Use MobyGames API for games.')
|
||||
.addToggle(cb => {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export class MediaTypeManager {
|
|||
mediaTemplateMap: Map<MediaType, string>;
|
||||
mediaFolderMap: Map<MediaType, string>;
|
||||
|
||||
constructor() {}
|
||||
constructor() { }
|
||||
|
||||
updateTemplates(settings: MediaDbPluginSettings): void {
|
||||
this.mediaFileNameTemplateMap = new Map<MediaType, string>();
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ export function unCamelCase(str: string): string {
|
|||
// space before last upper in a sequence followed by lower
|
||||
.replace(/\b([A-Z]+)([A-Z])([a-z])/, '$1 $2$3')
|
||||
// uppercase the first character
|
||||
.replace(/^./, function (str) {
|
||||
.replace(/^./, function(str) {
|
||||
return str.toUpperCase();
|
||||
})
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue