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 { 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 {
|
||||
declare settings: MediaDbPluginSettings;
|
||||
apiManager!: APIManager;
|
||||
|
|
@ -173,14 +171,14 @@ export default class MediaDbPlugin extends Plugin {
|
|||
}
|
||||
|
||||
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,
|
||||
value: diskSettings[key] as string,
|
||||
}));
|
||||
}
|
||||
|
||||
private removeLegacyApiKeys(settings: Record<string, unknown>): void {
|
||||
for (const key of LEGACY_API_KEYS) {
|
||||
for (const key of this.settings.LegacyApiKeys) {
|
||||
delete settings[key];
|
||||
}
|
||||
}
|
||||
|
|
@ -202,10 +200,8 @@ export default class MediaDbPlugin extends Plugin {
|
|||
this.app.workspace.onLayoutReady((): void => {
|
||||
window.setTimeout((): void => {
|
||||
new LegacyApiKeysModal(this.app, legacyEntries, (): void => {
|
||||
void (async (): Promise<void> => {
|
||||
this.removeLegacyApiKeys(this.settings as unknown as Record<string, unknown>);
|
||||
await this.saveSettings();
|
||||
})();
|
||||
this.removeLegacyApiKeys(this.settings as unknown as Record<string, unknown>);
|
||||
void this.saveSettings();
|
||||
}).open();
|
||||
}, 0);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ export interface MediaDbPluginSettings {
|
|||
ComicVineKeyId: string;
|
||||
BoardgameGeekKeyId: string;
|
||||
|
||||
LegacyApiKeys: readonly ['OMDbKey', 'TMDBKey', 'MobyGamesKey', 'GiantBombKey', 'ComicVineKey', 'BoardgameGeekKey'];
|
||||
|
||||
sfwFilter: boolean;
|
||||
templates: boolean;
|
||||
customDateFormat: string;
|
||||
|
|
@ -317,6 +319,8 @@ const DEFAULT_SETTINGS: MediaDbPluginSettings = {
|
|||
ComicVineKeyId: '',
|
||||
BoardgameGeekKeyId: '',
|
||||
|
||||
LegacyApiKeys: ['OMDbKey', 'TMDBKey', 'MobyGamesKey', 'GiantBombKey', 'ComicVineKey', 'BoardgameGeekKey'],
|
||||
|
||||
sfwFilter: true,
|
||||
templates: true,
|
||||
customDateFormat: 'L',
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ small.media-db-plugin-list-text {
|
|||
.media-db-plugin-legacy-keys-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
gap: var(--size-4-3);
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
|
@ -315,11 +315,11 @@ small.media-db-plugin-list-text {
|
|||
.media-db-plugin-legacy-keys-textarea {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
min-height: 100px;
|
||||
min-width: 500px;
|
||||
min-height: var(--size-4-5);
|
||||
min-width: var(--size-4-7);
|
||||
box-sizing: border-box;
|
||||
resize: vertical;
|
||||
padding: 0.75rem;
|
||||
padding: var(--size-4-3);
|
||||
border-radius: var(--radius-s);
|
||||
border: 1px solid var(--background-modifier-border);
|
||||
background: var(--background-primary);
|
||||
|
|
@ -330,5 +330,5 @@ small.media-db-plugin-list-text {
|
|||
white-space: pre;
|
||||
}
|
||||
.media-db-plugin-hidden {
|
||||
display: none !important;
|
||||
display: none;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue