fix some small things

This commit is contained in:
Moritz Jung 2024-06-22 15:53:07 +02:00
parent 4dcffab5b0
commit 1fb09395fd
4 changed files with 14 additions and 21 deletions

View file

@ -17,20 +17,17 @@ export class APIManager {
async query(query: string, apisToQuery: string[]): Promise<MediaTypeModel[]> {
console.debug(`MDB | api manager queried with "${query}"`);
let res: MediaTypeModel[] = [];
for (const api of this.apis) {
if (apisToQuery.contains(api.apiName)) {
const promises = this.apis
.filter(api => apisToQuery.contains(api.apiName))
.map(async api => {
try {
const apiRes = await api.searchByTitle(query);
res = res.concat(apiRes);
return await api.searchByTitle(query);
} catch (e) {
console.warn(e);
}
}
}
});
return res;
return (await Promise.all(promises)).flat();
}
/**

View file

@ -18,22 +18,17 @@ export abstract class APIModel {
abstract getById(id: string): Promise<MediaTypeModel>;
hasType(_type: MediaType): boolean {
hasType(type: MediaType): boolean {
// if (
// this.types.contains(type) &&
// (Boolean((this.plugin.settings.apiToggle as any)?.[this.apiName]?.[type]) === true || (this.plugin.settings.apiToggle as any)?.[this.apiName]?.[type] === undefined)
// ) {
// return true;
// }
return true;
return this.types.contains(type);
}
hasTypeOverlap(types: MediaType[]): boolean {
for (const type of types) {
if (this.hasType(type)) {
return true;
}
}
return false;
return types.some(type => this.hasType(type));
}
}