Applied review suggestions
This commit is contained in:
parent
e1ab585103
commit
f176a12d6f
3 changed files with 13 additions and 13 deletions
|
|
@ -33,8 +33,6 @@ import { MEDIA_TYPES } from 'packages/obsidian/src/utils/MediaTypeManager';
|
||||||
import { ModalHelper } from 'packages/obsidian/src/utils/ModalHelper';
|
import { ModalHelper } from 'packages/obsidian/src/utils/ModalHelper';
|
||||||
import { unCamelCase } from 'packages/obsidian/src/utils/Utils';
|
import { unCamelCase } from 'packages/obsidian/src/utils/Utils';
|
||||||
|
|
||||||
const LEGACY_API_KEYS = ['OMDbKey', 'TMDBKey', 'MobyGamesKey', 'GiantBombKey', 'ComicVineKey', 'BoardgameGeekKey'] as const;
|
|
||||||
|
|
||||||
export default class MediaDbPlugin extends Plugin {
|
export default class MediaDbPlugin extends Plugin {
|
||||||
declare settings: MediaDbPluginSettings;
|
declare settings: MediaDbPluginSettings;
|
||||||
apiManager!: APIManager;
|
apiManager!: APIManager;
|
||||||
|
|
@ -173,14 +171,14 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getLegacyApiKeyEntries(diskSettings: Record<string, unknown>): LegacyApiKeyEntry[] {
|
private getLegacyApiKeyEntries(diskSettings: Record<string, unknown>): LegacyApiKeyEntry[] {
|
||||||
return LEGACY_API_KEYS.filter(key => typeof diskSettings[key] === 'string' && diskSettings[key].length > 0).map(key => ({
|
return this.settings.LegacyApiKeys.filter(key => typeof diskSettings[key] === 'string' && diskSettings[key].length > 0).map(key => ({
|
||||||
key,
|
key,
|
||||||
value: diskSettings[key] as string,
|
value: diskSettings[key] as string,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeLegacyApiKeys(settings: Record<string, unknown>): void {
|
private removeLegacyApiKeys(settings: Record<string, unknown>): void {
|
||||||
for (const key of LEGACY_API_KEYS) {
|
for (const key of this.settings.LegacyApiKeys) {
|
||||||
delete settings[key];
|
delete settings[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -202,10 +200,8 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
this.app.workspace.onLayoutReady((): void => {
|
this.app.workspace.onLayoutReady((): void => {
|
||||||
window.setTimeout((): void => {
|
window.setTimeout((): void => {
|
||||||
new LegacyApiKeysModal(this.app, legacyEntries, (): void => {
|
new LegacyApiKeysModal(this.app, legacyEntries, (): void => {
|
||||||
void (async (): Promise<void> => {
|
|
||||||
this.removeLegacyApiKeys(this.settings as unknown as Record<string, unknown>);
|
this.removeLegacyApiKeys(this.settings as unknown as Record<string, unknown>);
|
||||||
await this.saveSettings();
|
void this.saveSettings();
|
||||||
})();
|
|
||||||
}).open();
|
}).open();
|
||||||
}, 0);
|
}, 0);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ export interface MediaDbPluginSettings {
|
||||||
ComicVineKeyId: string;
|
ComicVineKeyId: string;
|
||||||
BoardgameGeekKeyId: string;
|
BoardgameGeekKeyId: string;
|
||||||
|
|
||||||
|
LegacyApiKeys: readonly ['OMDbKey', 'TMDBKey', 'MobyGamesKey', 'GiantBombKey', 'ComicVineKey', 'BoardgameGeekKey'];
|
||||||
|
|
||||||
sfwFilter: boolean;
|
sfwFilter: boolean;
|
||||||
templates: boolean;
|
templates: boolean;
|
||||||
customDateFormat: string;
|
customDateFormat: string;
|
||||||
|
|
@ -317,6 +319,8 @@ const DEFAULT_SETTINGS: MediaDbPluginSettings = {
|
||||||
ComicVineKeyId: '',
|
ComicVineKeyId: '',
|
||||||
BoardgameGeekKeyId: '',
|
BoardgameGeekKeyId: '',
|
||||||
|
|
||||||
|
LegacyApiKeys: ['OMDbKey', 'TMDBKey', 'MobyGamesKey', 'GiantBombKey', 'ComicVineKey', 'BoardgameGeekKey'],
|
||||||
|
|
||||||
sfwFilter: true,
|
sfwFilter: true,
|
||||||
templates: true,
|
templates: true,
|
||||||
customDateFormat: 'L',
|
customDateFormat: 'L',
|
||||||
|
|
|
||||||
|
|
@ -307,7 +307,7 @@ small.media-db-plugin-list-text {
|
||||||
.media-db-plugin-legacy-keys-wrapper {
|
.media-db-plugin-legacy-keys-wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 0.75rem;
|
gap: var(--size-4-3);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
@ -315,11 +315,11 @@ small.media-db-plugin-list-text {
|
||||||
.media-db-plugin-legacy-keys-textarea {
|
.media-db-plugin-legacy-keys-textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
min-height: 100px;
|
min-height: var(--size-4-5);
|
||||||
min-width: 500px;
|
min-width: var(--size-4-7);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
resize: vertical;
|
resize: vertical;
|
||||||
padding: 0.75rem;
|
padding: var(--size-4-3);
|
||||||
border-radius: var(--radius-s);
|
border-radius: var(--radius-s);
|
||||||
border: 1px solid var(--background-modifier-border);
|
border: 1px solid var(--background-modifier-border);
|
||||||
background: var(--background-primary);
|
background: var(--background-primary);
|
||||||
|
|
@ -330,5 +330,5 @@ small.media-db-plugin-list-text {
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
}
|
}
|
||||||
.media-db-plugin-hidden {
|
.media-db-plugin-hidden {
|
||||||
display: none !important;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue