update deps; fix preview modal
This commit is contained in:
parent
26cf166a54
commit
5125e73cb4
19 changed files with 1365 additions and 1302 deletions
|
|
@ -1,62 +1,60 @@
|
||||||
import esbuild from 'esbuild';
|
import esbuild from 'esbuild';
|
||||||
import process from 'process';
|
|
||||||
import builtins from 'builtin-modules';
|
import builtins from 'builtin-modules';
|
||||||
import esbuildSvelte from 'esbuild-svelte';
|
import esbuildSvelte from 'esbuild-svelte';
|
||||||
import sveltePreprocess from 'svelte-preprocess';
|
import sveltePreprocess from 'svelte-preprocess';
|
||||||
|
import manifest from './manifest.json' assert { type: 'json' };
|
||||||
|
|
||||||
const banner = `/*
|
const banner = `/*
|
||||||
|
-------------------------------------------
|
||||||
|
${manifest.name} - Release Build
|
||||||
|
-------------------------------------------
|
||||||
|
By: ${manifest.author} (${manifest.authorUrl})
|
||||||
|
Time: ${new Date().toUTCString()}
|
||||||
|
Version: ${manifest.version}
|
||||||
|
-------------------------------------------
|
||||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||||
if you want to view the source, please visit the github repository of this plugin
|
if you want to view the source, please visit the github repository of this plugin
|
||||||
*/
|
*/
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const prod = process.argv[2] === 'production';
|
const build = await esbuild.build({
|
||||||
|
banner: {
|
||||||
esbuild
|
js: banner,
|
||||||
.build({
|
},
|
||||||
banner: {
|
entryPoints: ['src/main.ts'],
|
||||||
js: banner,
|
bundle: true,
|
||||||
},
|
external: [
|
||||||
entryPoints: ['src/main.ts'],
|
'obsidian',
|
||||||
bundle: true,
|
'electron',
|
||||||
external: [
|
'@codemirror/autocomplete',
|
||||||
'obsidian',
|
'@codemirror/collab',
|
||||||
'electron',
|
'@codemirror/commands',
|
||||||
'@codemirror/autocomplete',
|
'@codemirror/language',
|
||||||
'@codemirror/closebrackets',
|
'@codemirror/lint',
|
||||||
'@codemirror/collab',
|
'@codemirror/search',
|
||||||
'@codemirror/commands',
|
'@codemirror/state',
|
||||||
'@codemirror/comment',
|
'@codemirror/view',
|
||||||
'@codemirror/fold',
|
'@lezer/common',
|
||||||
'@codemirror/gutter',
|
'@lezer/highlight',
|
||||||
'@codemirror/highlight',
|
'@lezer/lr',
|
||||||
'@codemirror/history',
|
...builtins,
|
||||||
'@codemirror/language',
|
],
|
||||||
'@codemirror/lint',
|
format: 'cjs',
|
||||||
'@codemirror/matchbrackets',
|
target: 'es2018',
|
||||||
'@codemirror/panel',
|
logLevel: 'info',
|
||||||
'@codemirror/rangeset',
|
sourcemap: false,
|
||||||
'@codemirror/rectangular-selection',
|
treeShaking: true,
|
||||||
'@codemirror/search',
|
outfile: 'main.js',
|
||||||
'@codemirror/state',
|
minify: true,
|
||||||
'@codemirror/stream-parser',
|
metafile: true,
|
||||||
'@codemirror/text',
|
plugins: [
|
||||||
'@codemirror/tooltip',
|
esbuildSvelte({
|
||||||
'@codemirror/view',
|
compilerOptions: { css: 'injected' },
|
||||||
...builtins,
|
preprocess: sveltePreprocess(),
|
||||||
],
|
filterWarnings: warning => {
|
||||||
format: 'cjs',
|
// we don't want warnings from node modules that we can do nothing about
|
||||||
watch: !prod,
|
return !warning.filename.includes('node_modules');
|
||||||
target: 'es2018',
|
},
|
||||||
logLevel: 'info',
|
}),
|
||||||
sourcemap: prod ? false : 'inline',
|
],
|
||||||
treeShaking: true,
|
});
|
||||||
outfile: 'main.js',
|
|
||||||
plugins: [
|
|
||||||
esbuildSvelte({
|
|
||||||
compilerOptions: { css: true },
|
|
||||||
preprocess: sveltePreprocess(),
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
})
|
|
||||||
.catch(() => process.exit(1));
|
|
||||||
|
|
|
||||||
63
esbuild.dev.config.mjs
Normal file
63
esbuild.dev.config.mjs
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
import esbuild from 'esbuild';
|
||||||
|
import process from 'process';
|
||||||
|
import builtins from 'builtin-modules';
|
||||||
|
import esbuildSvelte from 'esbuild-svelte';
|
||||||
|
import sveltePreprocess from 'svelte-preprocess';
|
||||||
|
import manifest from './manifest.json' assert { type: 'json' };
|
||||||
|
|
||||||
|
const banner = `/*
|
||||||
|
-------------------------------------------
|
||||||
|
${manifest.name} - Dev Build
|
||||||
|
-------------------------------------------
|
||||||
|
By: ${manifest.author} (${manifest.authorUrl})
|
||||||
|
Time: ${new Date().toUTCString()}
|
||||||
|
Version: Dev Build
|
||||||
|
-------------------------------------------
|
||||||
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||||
|
if you want to view the source, please visit the github repository of this plugin
|
||||||
|
*/
|
||||||
|
`;
|
||||||
|
|
||||||
|
const context = await esbuild
|
||||||
|
.context({
|
||||||
|
banner: {
|
||||||
|
js: banner,
|
||||||
|
},
|
||||||
|
entryPoints: ['src/main.ts'],
|
||||||
|
bundle: true,
|
||||||
|
external: [
|
||||||
|
'obsidian',
|
||||||
|
'electron',
|
||||||
|
'@codemirror/autocomplete',
|
||||||
|
'@codemirror/collab',
|
||||||
|
'@codemirror/commands',
|
||||||
|
'@codemirror/language',
|
||||||
|
'@codemirror/lint',
|
||||||
|
'@codemirror/search',
|
||||||
|
'@codemirror/state',
|
||||||
|
'@codemirror/view',
|
||||||
|
'@lezer/common',
|
||||||
|
'@lezer/highlight',
|
||||||
|
'@lezer/lr',
|
||||||
|
...builtins,
|
||||||
|
],
|
||||||
|
format: 'cjs',
|
||||||
|
target: 'es2018',
|
||||||
|
logLevel: 'info',
|
||||||
|
sourcemap: 'inline',
|
||||||
|
treeShaking: true,
|
||||||
|
outfile: 'main.js',
|
||||||
|
plugins: [
|
||||||
|
esbuildSvelte({
|
||||||
|
compilerOptions: { css: 'injected' },
|
||||||
|
preprocess: sveltePreprocess(),
|
||||||
|
filterWarnings: warning => {
|
||||||
|
// we don't want warnings from node modules that we can do nothing about
|
||||||
|
return !warning.filename.includes('node_modules');
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
.catch(() => process.exit(1));
|
||||||
|
|
||||||
|
await context.watch();
|
||||||
2401
package-lock.json
generated
2401
package-lock.json
generated
File diff suppressed because it is too large
Load diff
37
package.json
37
package.json
|
|
@ -4,7 +4,7 @@
|
||||||
"description": "A plugin that can query multiple APIs for movies, series, anime, games, music and wiki articles, and import them into your vault.",
|
"description": "A plugin that can query multiple APIs for movies, series, anime, games, music and wiki articles, and import them into your vault.",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "node esbuild.config.mjs",
|
"dev": "node esbuild.dev.config.mjs",
|
||||||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
||||||
"version": "node version-bump.mjs && git add manifest.json versions.json",
|
"version": "node version-bump.mjs && git add manifest.json versions.json",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
|
|
@ -14,25 +14,24 @@
|
||||||
"author": "Moritz Jung",
|
"author": "Moritz Jung",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@popperjs/core": "^2.11.5",
|
"@popperjs/core": "^2.11.8",
|
||||||
"@tsconfig/svelte": "^3.0.0",
|
"@tsconfig/svelte": "^5.0.2",
|
||||||
"@types/jest": "^29.5.3",
|
"@types/jest": "^29.5.11",
|
||||||
"@types/node": "^18.16.20",
|
"@types/node": "^20.10.4",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.30.0",
|
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
||||||
"@typescript-eslint/parser": "^5.30.0",
|
"@typescript-eslint/parser": "^6.14.0",
|
||||||
"builtin-modules": "^3.3.0",
|
"builtin-modules": "^3.3.0",
|
||||||
"esbuild": "^0.14.47",
|
"esbuild": "^0.19.9",
|
||||||
"esbuild-svelte": "^0.7.1",
|
"esbuild-svelte": "^0.8.0",
|
||||||
"eslint-plugin-only-warn": "^1.0.3",
|
"eslint-plugin-only-warn": "^1.1.0",
|
||||||
"jest": "^29.6.1",
|
"jest": "^29.7.0",
|
||||||
"jest-fetch-mock": "^3.0.3",
|
"jest-fetch-mock": "^3.0.3",
|
||||||
"obsidian": "latest",
|
"obsidian": "^1.4.11",
|
||||||
"svelte": "^3.53.1",
|
"prettier": "3.1.1",
|
||||||
"svelte-preprocess": "^4.10.7",
|
"svelte": "^4.2.8",
|
||||||
|
"svelte-preprocess": "^5.1.2",
|
||||||
"ts-jest": "^29.1.1",
|
"ts-jest": "^29.1.1",
|
||||||
"tslib": "2.4.0",
|
"tslib": "2.6.2",
|
||||||
"typescript": "^4.9.5",
|
"typescript": "^5.3.3"
|
||||||
"prettier": "2.7.1"
|
}
|
||||||
},
|
|
||||||
"dependencies": {}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ export class BoardGameGeekAPI extends APIModel {
|
||||||
title,
|
title,
|
||||||
englishTitle: title,
|
englishTitle: title,
|
||||||
year,
|
year,
|
||||||
} as BoardGameModel)
|
} as BoardGameModel),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ export class MALAPI extends APIModel {
|
||||||
year: result.year ?? result.aired?.prop?.from?.year ?? '',
|
year: result.year ?? result.aired?.prop?.from?.year ?? '',
|
||||||
dataSource: this.apiName,
|
dataSource: this.apiName,
|
||||||
id: result.mal_id,
|
id: result.mal_id,
|
||||||
} as MovieModel)
|
} as MovieModel),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (type === 'movie' || type === 'special') {
|
if (type === 'movie' || type === 'special') {
|
||||||
|
|
@ -64,7 +64,7 @@ export class MALAPI extends APIModel {
|
||||||
year: result.year ?? result.aired?.prop?.from?.year ?? '',
|
year: result.year ?? result.aired?.prop?.from?.year ?? '',
|
||||||
dataSource: this.apiName,
|
dataSource: this.apiName,
|
||||||
id: result.mal_id,
|
id: result.mal_id,
|
||||||
} as MovieModel)
|
} as MovieModel),
|
||||||
);
|
);
|
||||||
} else if (type === 'series' || type === 'ova') {
|
} else if (type === 'series' || type === 'ova') {
|
||||||
ret.push(
|
ret.push(
|
||||||
|
|
@ -75,7 +75,7 @@ export class MALAPI extends APIModel {
|
||||||
year: result.year ?? result.aired?.prop?.from?.year ?? '',
|
year: result.year ?? result.aired?.prop?.from?.year ?? '',
|
||||||
dataSource: this.apiName,
|
dataSource: this.apiName,
|
||||||
id: result.mal_id,
|
id: result.mal_id,
|
||||||
} as SeriesModel)
|
} as SeriesModel),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ export class MALAPIManga extends APIModel {
|
||||||
lastWatched: '',
|
lastWatched: '',
|
||||||
personalRating: 0,
|
personalRating: 0,
|
||||||
},
|
},
|
||||||
} as MangaModel)
|
} as MangaModel),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ export class MusicBrainzAPI extends APIModel {
|
||||||
|
|
||||||
artists: result['artist-credit'].map((a: any) => a.name),
|
artists: result['artist-credit'].map((a: any) => a.name),
|
||||||
subType: result['primary-type'],
|
subType: result['primary-type'],
|
||||||
} as MusicReleaseModel)
|
} as MusicReleaseModel),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ export class OMDbAPI extends APIModel {
|
||||||
year: result.Year,
|
year: result.Year,
|
||||||
dataSource: this.apiName,
|
dataSource: this.apiName,
|
||||||
id: result.imdbID,
|
id: result.imdbID,
|
||||||
} as MovieModel)
|
} as MovieModel),
|
||||||
);
|
);
|
||||||
} else if (type === 'series') {
|
} else if (type === 'series') {
|
||||||
ret.push(
|
ret.push(
|
||||||
|
|
@ -80,7 +80,7 @@ export class OMDbAPI extends APIModel {
|
||||||
year: result.Year,
|
year: result.Year,
|
||||||
dataSource: this.apiName,
|
dataSource: this.apiName,
|
||||||
id: result.imdbID,
|
id: result.imdbID,
|
||||||
} as SeriesModel)
|
} as SeriesModel),
|
||||||
);
|
);
|
||||||
} else if (type === 'game') {
|
} else if (type === 'game') {
|
||||||
ret.push(
|
ret.push(
|
||||||
|
|
@ -91,7 +91,7 @@ export class OMDbAPI extends APIModel {
|
||||||
year: result.Year,
|
year: result.Year,
|
||||||
dataSource: this.apiName,
|
dataSource: this.apiName,
|
||||||
id: result.imdbID,
|
id: result.imdbID,
|
||||||
} as GameModel)
|
} as GameModel),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ export class OpenLibraryAPI extends APIModel {
|
||||||
year: result.first_publish_year,
|
year: result.first_publish_year,
|
||||||
dataSource: this.apiName,
|
dataSource: this.apiName,
|
||||||
id: result.key,
|
id: result.key,
|
||||||
} as BookModel)
|
} as BookModel),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ export class OpenLibraryAPI extends APIModel {
|
||||||
plot: result.description ?? 'unknown',
|
plot: result.description ?? 'unknown',
|
||||||
pages: result.number_of_pages_median ?? 'unknown',
|
pages: result.number_of_pages_median ?? 'unknown',
|
||||||
onlineRating: Number.parseFloat(Number(result.ratings_average ?? 0).toFixed(2)),
|
onlineRating: Number.parseFloat(Number(result.ratings_average ?? 0).toFixed(2)),
|
||||||
image: `https://covers.openlibrary.org/b/OLID/` + result.cover_edition_key + `-L.jpg` ?? '',
|
image: `https://covers.openlibrary.org/b/OLID/` + result.cover_edition_key + `-L.jpg`,
|
||||||
|
|
||||||
released: true,
|
released: true,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ export class SteamAPI extends APIModel {
|
||||||
year: '',
|
year: '',
|
||||||
dataSource: this.apiName,
|
dataSource: this.apiName,
|
||||||
id: result.appid,
|
id: result.appid,
|
||||||
} as GameModel)
|
} as GameModel),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ export class WikipediaAPI extends APIModel {
|
||||||
year: '',
|
year: '',
|
||||||
dataSource: this.apiName,
|
dataSource: this.apiName,
|
||||||
id: result.pageid,
|
id: result.pageid,
|
||||||
} as WikiModel)
|
} as WikiModel),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
.onClick(() => this.createEntriesFromFolder(file));
|
.onClick(() => this.createEntriesFromFolder(file));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
// register command to open search modal
|
// register command to open search modal
|
||||||
|
|
@ -291,6 +291,11 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generateMediaDbNoteFrontmatterPreview(mediaTypeModel: MediaTypeModel): string {
|
||||||
|
const fileMetadata = this.modelPropertyMapper.convertObject(mediaTypeModel.toMetaDataObject());
|
||||||
|
return this.settings.useCustomYamlStringifier ? YAMLConverter.toYaml(fileMetadata) : stringifyYaml(fileMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
async generateMediaDbNoteContents(mediaTypeModel: MediaTypeModel, options: CreateNoteOptions): Promise<string> {
|
async generateMediaDbNoteContents(mediaTypeModel: MediaTypeModel, options: CreateNoteOptions): Promise<string> {
|
||||||
let fileMetadata = this.modelPropertyMapper.convertObject(mediaTypeModel.toMetaDataObject());
|
let fileMetadata = this.modelPropertyMapper.convertObject(mediaTypeModel.toMetaDataObject());
|
||||||
let fileContent = '';
|
let fileContent = '';
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ export class MediaDbPreviewModal extends Modal {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.title = previewModalOptions.modalTitle;
|
this.title = previewModalOptions.modalTitle;
|
||||||
this.elements = previewModalOptions.elements;
|
this.elements = previewModalOptions.elements;
|
||||||
this.createNoteOptions = previewModalOptions.createNoteOptions;
|
|
||||||
|
|
||||||
this.markdownComponent = new Component();
|
this.markdownComponent = new Component();
|
||||||
}
|
}
|
||||||
|
|
@ -53,8 +52,8 @@ export class MediaDbPreviewModal extends Modal {
|
||||||
previewWrapper.createEl('h3', { text: result.englishTitle });
|
previewWrapper.createEl('h3', { text: result.englishTitle });
|
||||||
const fileDiv = previewWrapper.createDiv({ cls: 'media-db-plugin-preview' });
|
const fileDiv = previewWrapper.createDiv({ cls: 'media-db-plugin-preview' });
|
||||||
|
|
||||||
let fileContent = await this.plugin.generateMediaDbNoteContents(result, this.createNoteOptions);
|
let fileContent = this.plugin.generateMediaDbNoteFrontmatterPreview(result);
|
||||||
fileContent = `\n${fileContent}\n`;
|
fileContent = `\`\`\`yaml\n${fileContent}\`\`\``;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO: fix this not rendering the frontmatter any more
|
// TODO: fix this not rendering the frontmatter any more
|
||||||
|
|
@ -83,7 +82,7 @@ export class MediaDbPreviewModal extends Modal {
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpen(): void {
|
onOpen(): void {
|
||||||
this.preview();
|
void this.preview();
|
||||||
}
|
}
|
||||||
|
|
||||||
onClose(): void {
|
onClose(): void {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ export class PropertyMappingModel {
|
||||||
return {
|
return {
|
||||||
res: false,
|
res: false,
|
||||||
err: new PropertyMappingNameConflictError(
|
err: new PropertyMappingNameConflictError(
|
||||||
`Multiple remapped properties (${propertiesWithSameTarget.map(x => x.toString()).toString()}) may not share the same name.`
|
`Multiple remapped properties (${propertiesWithSameTarget.map(x => x.toString()).toString()}) may not share the same name.`,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -192,8 +192,8 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
||||||
"For more syntax, refer to <a href='https://momentjs.com/docs/#/displaying/format/'>format reference</a>.<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;'>" +
|
"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() +
|
this.plugin.dateFormatter.getPreview() +
|
||||||
'</a></b>'
|
'</a></b>',
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
.addText(cb => {
|
.addText(cb => {
|
||||||
cb.setPlaceholder(DEFAULT_SETTINGS.customDateFormat)
|
cb.setPlaceholder(DEFAULT_SETTINGS.customDateFormat)
|
||||||
|
|
|
||||||
|
|
@ -100,5 +100,5 @@ describe.each([{ name: OMDbAPI }, { name: MALAPI }, { name: LocGovAPI }, { name:
|
||||||
await expect(apiMock.searchByTitle('Hooking Season Playtest')).resolves.toEqual(ret);
|
await expect(apiMock.searchByTitle('Hooking Season Playtest')).resolves.toEqual(ret);
|
||||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ export function setWikipediaResponseMock() {
|
||||||
year: '',
|
year: '',
|
||||||
dataSource: apiMock.apiName,
|
dataSource: apiMock.apiName,
|
||||||
id: wikiresponse.pageid,
|
id: wikiresponse.pageid,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +37,7 @@ export function setOMDbResponseMock() {
|
||||||
year: omdbresponse.Year,
|
year: omdbresponse.Year,
|
||||||
dataSource: apiMock.apiName,
|
dataSource: apiMock.apiName,
|
||||||
id: omdbresponse.imdbID,
|
id: omdbresponse.imdbID,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -53,7 +53,7 @@ export function setMALResponseMock() {
|
||||||
year: result.aired.prop.from.year,
|
year: result.aired.prop.from.year,
|
||||||
dataSource: apiMock.apiName,
|
dataSource: apiMock.apiName,
|
||||||
id: result.mal_id,
|
id: result.mal_id,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -69,7 +69,7 @@ export function setSteamResponseMock() {
|
||||||
year: '',
|
year: '',
|
||||||
dataSource: apiMock.apiName,
|
dataSource: apiMock.apiName,
|
||||||
id: steamResponse.appid,
|
id: steamResponse.appid,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +89,7 @@ export function setMusicBrainzResponseMock() {
|
||||||
|
|
||||||
artists: result['artist-credit'].map((a: any) => a.name),
|
artists: result['artist-credit'].map((a: any) => a.name),
|
||||||
subType: result['primary-type'],
|
subType: result['primary-type'],
|
||||||
} as MusicReleaseModel)
|
} as MusicReleaseModel),
|
||||||
);
|
);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,6 @@ export interface SelectModalOptions {
|
||||||
export interface PreviewModalOptions {
|
export interface PreviewModalOptions {
|
||||||
modalTitle?: string;
|
modalTitle?: string;
|
||||||
elements?: MediaTypeModel[];
|
elements?: MediaTypeModel[];
|
||||||
createNoteOptions?: CreateNoteOptions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SEARCH_MODAL_DEFAULT_OPTIONS: SearchModalOptions = {
|
export const SEARCH_MODAL_DEFAULT_OPTIONS: SearchModalOptions = {
|
||||||
|
|
@ -206,7 +205,6 @@ export const SELECT_MODAL_OPTIONS_DEFAULT: SelectModalOptions = {
|
||||||
export const PREVIEW_MODAL_DEFAULT_OPTIONS: PreviewModalOptions = {
|
export const PREVIEW_MODAL_DEFAULT_OPTIONS: PreviewModalOptions = {
|
||||||
modalTitle: 'Media DB Preview',
|
modalTitle: 'Media DB Preview',
|
||||||
elements: [],
|
elements: [],
|
||||||
createNoteOptions: { attachTemplate: true },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -289,7 +287,7 @@ export class ModalHelper {
|
||||||
* @returns the user input or nothing and a reference to the modal.
|
* @returns the user input or nothing and a reference to the modal.
|
||||||
*/
|
*/
|
||||||
async createAdvancedSearchModal(
|
async createAdvancedSearchModal(
|
||||||
advancedSearchModalOptions: AdvancedSearchModalOptions
|
advancedSearchModalOptions: AdvancedSearchModalOptions,
|
||||||
): Promise<{ advancedSearchModalResult: AdvancedSearchModalResult; advancedSearchModal: MediaDbAdvancedSearchModal }> {
|
): Promise<{ advancedSearchModalResult: AdvancedSearchModalResult; advancedSearchModal: MediaDbAdvancedSearchModal }> {
|
||||||
const modal = new MediaDbAdvancedSearchModal(this.plugin, advancedSearchModalOptions);
|
const modal = new MediaDbAdvancedSearchModal(this.plugin, advancedSearchModalOptions);
|
||||||
const res: AdvancedSearchModalResult = await new Promise(resolve => {
|
const res: AdvancedSearchModalResult = await new Promise(resolve => {
|
||||||
|
|
@ -316,7 +314,7 @@ export class ModalHelper {
|
||||||
*/
|
*/
|
||||||
async openAdvancedSearchModal(
|
async openAdvancedSearchModal(
|
||||||
advancedSearchModalOptions: AdvancedSearchModalOptions,
|
advancedSearchModalOptions: AdvancedSearchModalOptions,
|
||||||
submitCallback: (advancedSearchModalData: AdvancedSearchModalData) => Promise<MediaTypeModel[]>
|
submitCallback: (advancedSearchModalData: AdvancedSearchModalData) => Promise<MediaTypeModel[]>,
|
||||||
): Promise<MediaTypeModel[]> {
|
): Promise<MediaTypeModel[]> {
|
||||||
const { advancedSearchModalResult, advancedSearchModal } = await this.createAdvancedSearchModal(advancedSearchModalOptions);
|
const { advancedSearchModalResult, advancedSearchModal } = await this.createAdvancedSearchModal(advancedSearchModalOptions);
|
||||||
console.debug(`MDB | advencedSearchModal closed with code ${advancedSearchModalResult.code}`);
|
console.debug(`MDB | advencedSearchModal closed with code ${advancedSearchModalResult.code}`);
|
||||||
|
|
@ -380,7 +378,7 @@ export class ModalHelper {
|
||||||
*/
|
*/
|
||||||
async openIdSearchModal(
|
async openIdSearchModal(
|
||||||
idSearchModalOptions: IdSearchModalOptions,
|
idSearchModalOptions: IdSearchModalOptions,
|
||||||
submitCallback: (idSearchModalData: IdSearchModalData) => Promise<MediaTypeModel>
|
submitCallback: (idSearchModalData: IdSearchModalData) => Promise<MediaTypeModel>,
|
||||||
): Promise<MediaTypeModel> {
|
): Promise<MediaTypeModel> {
|
||||||
const { idSearchModalResult, idSearchModal } = await this.createIdSearchModal(idSearchModalOptions);
|
const { idSearchModalResult, idSearchModal } = await this.createIdSearchModal(idSearchModalOptions);
|
||||||
console.debug(`MDB | idSearchModal closed with code ${idSearchModalResult.code}`);
|
console.debug(`MDB | idSearchModal closed with code ${idSearchModalResult.code}`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue