fix lint errors and ran bun run check:fix
This commit is contained in:
parent
54f971f609
commit
e1ab585103
3 changed files with 78 additions and 71 deletions
|
|
@ -173,7 +173,7 @@ 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 LEGACY_API_KEYS.filter(key => typeof diskSettings[key] === 'string' && diskSettings[key].length > 0).map(key => ({
|
||||
key,
|
||||
value: diskSettings[key] as string,
|
||||
}));
|
||||
|
|
@ -199,11 +199,13 @@ export default class MediaDbPlugin extends Plugin {
|
|||
|
||||
const legacyEntries = this.getLegacyApiKeyEntries(diskSettings);
|
||||
if (legacyEntries.length > 0) {
|
||||
this.app.workspace.onLayoutReady(() => {
|
||||
window.setTimeout(() => {
|
||||
new LegacyApiKeysModal(this.app, legacyEntries, async () => {
|
||||
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();
|
||||
})();
|
||||
}).open();
|
||||
}, 0);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -26,7 +26,11 @@ export class LegacyApiKeysModal extends Modal {
|
|||
|
||||
const intro = wrapper.createDiv({ cls: 'media-db-plugin-legacy-keys-intro' });
|
||||
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', {
|
||||
|
|
@ -38,7 +42,7 @@ export class LegacyApiKeysModal extends Modal {
|
|||
});
|
||||
|
||||
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' });
|
||||
|
||||
|
|
@ -57,13 +61,12 @@ export class LegacyApiKeysModal extends Modal {
|
|||
btn.setButtonText('Show keys');
|
||||
|
||||
btn.onClick(() => {
|
||||
const isHidden = textarea.style.display === 'none';
|
||||
|
||||
const isHidden = textarea.hasClass('media-db-plugin-hidden');
|
||||
if (isHidden) {
|
||||
textarea.style.display = '';
|
||||
textarea.removeClass('media-db-plugin-hidden');
|
||||
btn.setButtonText('Hide keys');
|
||||
} else {
|
||||
textarea.style.display = 'none';
|
||||
textarea.addClass('media-db-plugin-hidden');
|
||||
btn.setButtonText('Show keys');
|
||||
}
|
||||
});
|
||||
|
|
@ -81,7 +84,6 @@ export class LegacyApiKeysModal extends Modal {
|
|||
btn.buttonEl.addClass('media-db-plugin-button');
|
||||
btn.buttonEl.addClass('mod-warning');
|
||||
btn.buttonEl.addClass('mod-danger');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -329,3 +329,6 @@ small.media-db-plugin-list-text {
|
|||
line-height: 1.5;
|
||||
white-space: pre;
|
||||
}
|
||||
.media-db-plugin-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue