diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-02-01 10:00:59 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-01 15:00:59 +0000 |
commit | dfd42bad0b46845ad88d1fdc5fa82b4f03bab0f3 (patch) | |
tree | 04686b943b84b33b8927238be17e4bc0dda7eb62 /ext/js/display/display-anki.js | |
parent | 2356223942a21d1683ac38eed8e7b9485f453d87 (diff) |
Application refactor (#591)
* Rename Yomitan class to Application, change initialization style
* Rename file
* Update init
* Update config
* Remove dead code
Diffstat (limited to 'ext/js/display/display-anki.js')
-rw-r--r-- | ext/js/display/display-anki.js | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js index 68d28d33..c19cfa22 100644 --- a/ext/js/display/display-anki.js +++ b/ext/js/display/display-anki.js @@ -24,7 +24,6 @@ import {isNoteDataValid} from '../data/anki-util.js'; import {PopupMenu} from '../dom/popup-menu.js'; import {querySelectorNotNull} from '../dom/query-selector.js'; import {TemplateRendererProxy} from '../templates/template-renderer-proxy.js'; -import {yomitan} from '../yomitan.js'; export class DisplayAnki { /** @@ -41,7 +40,7 @@ export class DisplayAnki { /** @type {?string} */ this._ankiFieldTemplatesDefault = null; /** @type {AnkiNoteBuilder} */ - this._ankiNoteBuilder = new AnkiNoteBuilder(new TemplateRendererProxy()); + this._ankiNoteBuilder = new AnkiNoteBuilder(display.application.api, new TemplateRendererProxy()); /** @type {?import('./display-notification.js').DisplayNotification} */ this._errorNotification = null; /** @type {?EventListenerCollection} */ @@ -487,7 +486,7 @@ export class DisplayAnki { let noteId = null; let addNoteOkay = false; try { - noteId = await yomitan.api.addAnkiNote(note); + noteId = await this._display.application.api.addAnkiNote(note); addNoteOkay = true; } catch (e) { allErrors.length = 0; @@ -500,7 +499,7 @@ export class DisplayAnki { } else { if (this._suspendNewCards) { try { - await yomitan.api.suspendAnkiCardsForNote(noteId); + await this._display.application.api.suspendAnkiCardsForNote(noteId); } catch (e) { allErrors.push(toError(e)); } @@ -605,7 +604,7 @@ export class DisplayAnki { templates = this._ankiFieldTemplatesDefault; if (typeof templates === 'string') { return templates; } - templates = await yomitan.api.getDefaultAnkiFieldTemplates(); + templates = await this._display.application.api.getDefaultAnkiFieldTemplates(); this._ankiFieldTemplatesDefault = templates; return templates; } @@ -639,12 +638,12 @@ export class DisplayAnki { let ankiError = null; try { if (forceCanAddValue !== null) { - if (!await yomitan.api.isAnkiConnected()) { + if (!await this._display.application.api.isAnkiConnected()) { throw new Error('Anki not connected'); } infos = this._getAnkiNoteInfoForceValue(notes, forceCanAddValue); } else { - infos = await yomitan.api.getAnkiNoteInfo(notes, fetchAdditionalInfo); + infos = await this._display.application.api.getAnkiNoteInfo(notes, fetchAdditionalInfo); } } catch (e) { infos = this._getAnkiNoteInfoForceValue(notes, false); @@ -853,7 +852,7 @@ export class DisplayAnki { const noteIds = this._getNodeNoteIds(node); if (noteIds.length === 0) { return; } try { - await yomitan.api.noteView(noteIds[0], this._noteGuiMode, false); + await this._display.application.api.noteView(noteIds[0], this._noteGuiMode, false); } catch (e) { const displayErrors = ( toError(e).message === 'Mode not supported' ? |