fix lint errors and ran bun run check:fix

This commit is contained in:
ltctceplrm 2026-06-21 20:06:38 +02:00
parent 54f971f609
commit e1ab585103
3 changed files with 78 additions and 71 deletions

View file

@ -173,7 +173,7 @@ 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 LEGACY_API_KEYS.filter(key => typeof diskSettings[key] === 'string' && diskSettings[key].length > 0).map(key => ({
key, key,
value: diskSettings[key] as string, value: diskSettings[key] as string,
})); }));
@ -199,11 +199,13 @@ export default class MediaDbPlugin extends Plugin {
const legacyEntries = this.getLegacyApiKeyEntries(diskSettings); const legacyEntries = this.getLegacyApiKeyEntries(diskSettings);
if (legacyEntries.length > 0) { if (legacyEntries.length > 0) {
this.app.workspace.onLayoutReady(() => { this.app.workspace.onLayoutReady((): void => {
window.setTimeout(() => { window.setTimeout((): void => {
new LegacyApiKeysModal(this.app, legacyEntries, async () => { 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(); await this.saveSettings();
})();
}).open(); }).open();
}, 0); }, 0);
}); });

View file

@ -26,7 +26,11 @@ export class LegacyApiKeysModal extends Modal {
const intro = wrapper.createDiv({ cls: 'media-db-plugin-legacy-keys-intro' }); const intro = wrapper.createDiv({ cls: 'media-db-plugin-legacy-keys-intro' });
intro.createEl('p', { intro.createEl('p', {
text: 'Media DB plugin has found old plaintext API keys in your settings. Copy them now if needed, they should be removed for safety. The new keychain-backed system will be used instead. The plugin will not be usable until the old plaintext keys have been deleted.', text: 'Media DB plugin has found old plaintext API keys in your settings. Copy them now if needed, they should be removed for safety.',
});
intro.createEl('p', {
text: 'The new keychain-backed system will be used instead. The plugin will not be usable until the old plaintext keys have been deleted.',
}); });
const textarea = wrapper.createEl('textarea', { const textarea = wrapper.createEl('textarea', {
@ -38,7 +42,7 @@ export class LegacyApiKeysModal extends Modal {
}); });
textarea.value = this.entries.map(e => `${e.key}: ${e.value}`).join('\n'); textarea.value = this.entries.map(e => `${e.key}: ${e.value}`).join('\n');
textarea.style.display = 'none'; textarea.addClass('media-db-plugin-hidden');
contentEl.createDiv({ cls: 'media-db-plugin-spacer' }); contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
@ -57,13 +61,12 @@ export class LegacyApiKeysModal extends Modal {
btn.setButtonText('Show keys'); btn.setButtonText('Show keys');
btn.onClick(() => { btn.onClick(() => {
const isHidden = textarea.style.display === 'none'; const isHidden = textarea.hasClass('media-db-plugin-hidden');
if (isHidden) { if (isHidden) {
textarea.style.display = ''; textarea.removeClass('media-db-plugin-hidden');
btn.setButtonText('Hide keys'); btn.setButtonText('Hide keys');
} else { } else {
textarea.style.display = 'none'; textarea.addClass('media-db-plugin-hidden');
btn.setButtonText('Show keys'); btn.setButtonText('Show keys');
} }
}); });
@ -81,7 +84,6 @@ export class LegacyApiKeysModal extends Modal {
btn.buttonEl.addClass('media-db-plugin-button'); btn.buttonEl.addClass('media-db-plugin-button');
btn.buttonEl.addClass('mod-warning'); btn.buttonEl.addClass('mod-warning');
btn.buttonEl.addClass('mod-danger'); btn.buttonEl.addClass('mod-danger');
}); });
} }

View file

@ -329,3 +329,6 @@ small.media-db-plugin-list-text {
line-height: 1.5; line-height: 1.5;
white-space: pre; white-space: pre;
} }
.media-db-plugin-hidden {
display: none !important;
}