From 7a4096240ce4faf70a785d047945388baa0daab3 Mon Sep 17 00:00:00 2001 From: Eloy Robillard Date: Thu, 15 Feb 2024 04:02:36 +0100 Subject: Show all duplicate notes on click (#636) * Show all duplicate notes on click * Change 'notesView' to 'viewNotes' * Replace api.noteView with api.viewNotes * Update "viewNote" action to "viewNotes" in options util * Update options-util test with "viewNotes" action * Replace uses of "viewNote" with "viewNotes" * Replace _viewNote with _viewNotes * Rename /*ViewNote*/ methods to /*ViewNotes*/ --- ext/js/background/backend.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'ext/js/background') diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 8b5e8383..090ba7b3 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -154,7 +154,7 @@ export class Backend { ['addAnkiNote', this._onApiAddAnkiNote.bind(this)], ['getAnkiNoteInfo', this._onApiGetAnkiNoteInfo.bind(this)], ['injectAnkiNoteMedia', this._onApiInjectAnkiNoteMedia.bind(this)], - ['noteView', this._onApiNoteView.bind(this)], + ['viewNotes', this._onApiViewNotes.bind(this)], ['suspendAnkiCardsForNote', this._onApiSuspendAnkiCardsForNote.bind(this)], ['commandExec', this._onApiCommandExec.bind(this)], ['getTermAudioInfoList', this._onApiGetTermAudioInfoList.bind(this)], @@ -580,11 +580,11 @@ export class Backend { ); } - /** @type {import('api').ApiHandler<'noteView'>} */ - async _onApiNoteView({noteId, mode, allowFallback}) { - if (mode === 'edit') { + /** @type {import('api').ApiHandler<'viewNotes'>} */ + async _onApiViewNotes({noteIds, mode, allowFallback}) { + if (noteIds.length === 1 && mode === 'edit') { try { - await this._anki.guiEditNote(noteId); + await this._anki.guiEditNote(noteIds[0]); return 'edit'; } catch (e) { if (!(e instanceof Error && this._anki.isErrorUnsupportedAction(e))) { @@ -594,8 +594,7 @@ export class Backend { } } } - // Fallback - await this._anki.guiBrowseNote(noteId); + await this._anki.guiBrowseNotes(noteIds); return 'browse'; } -- cgit v1.2.3