summaryrefslogtreecommitdiff
path: root/ext/js
diff options
context:
space:
mode:
authorKuuuube <61125188+Kuuuube@users.noreply.github.com>2024-04-16 12:25:59 -0400
committerGitHub <noreply@github.com>2024-04-16 16:25:59 +0000
commit669d277a95908cec7b35e098b3252ae38db05df0 (patch)
tree54dffc4d9c566b941eea67ad8a070d967ed3c717 /ext/js
parent6e1cb327226d1f9dfc71ebff8063834a18db9dff (diff)
Fix duplicate check not working across note types (#830)24.4.16.0
* Fix duplicate check not working across note types * Add invalidNoteId --------- Co-authored-by: James Maa <jmaa@berkeley.edu>
Diffstat (limited to 'ext/js')
-rw-r--r--ext/js/background/backend.js6
-rw-r--r--ext/js/data/anki-util.js2
-rw-r--r--ext/js/display/display-anki.js8
3 files changed, 13 insertions, 3 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index deaef4a0..df0378b3 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -28,7 +28,7 @@ import {logErrorLevelToNumber} from '../core/log-utilities.js';
import {log} from '../core/log.js';
import {isObjectNotArray} from '../core/object-utilities.js';
import {clone, deferPromise, promiseTimeout} from '../core/utilities.js';
-import {isNoteDataValid} from '../data/anki-util.js';
+import {invalidNoteId, isNoteDataValid} from '../data/anki-util.js';
import {arrayBufferToBase64} from '../data/array-buffer-util.js';
import {OptionsUtil} from '../data/options-util.js';
import {getAllPermissions, hasPermissions, hasRequiredPermissionsForOptions} from '../data/permissions-util.js';
@@ -595,6 +595,10 @@ export class Backend {
const valid = isNoteDataValid(note);
+ if (isDuplicate && duplicateNoteIds[originalIndices.indexOf(i)].length === 0) {
+ duplicateNoteIds[originalIndices.indexOf(i)] = [invalidNoteId];
+ }
+
const noteIds = isDuplicate ? duplicateNoteIds[originalIndices.indexOf(i)] : null;
const noteInfos = (fetchAdditionalInfo && noteIds !== null && noteIds.length > 0) ? await this._anki.notesInfo(noteIds) : [];
diff --git a/ext/js/data/anki-util.js b/ext/js/data/anki-util.js
index eea3fb8b..a063980f 100644
--- a/ext/js/data/anki-util.js
+++ b/ext/js/data/anki-util.js
@@ -82,3 +82,5 @@ export function isNoteDataValid(note) {
Object.entries(fields).length > 0
);
}
+
+export const invalidNoteId = -1;
diff --git a/ext/js/display/display-anki.js b/ext/js/display/display-anki.js
index fd3e8dcd..dc676702 100644
--- a/ext/js/display/display-anki.js
+++ b/ext/js/display/display-anki.js
@@ -21,7 +21,7 @@ import {log} from '../core/log.js';
import {toError} from '../core/to-error.js';
import {deferPromise} from '../core/utilities.js';
import {AnkiNoteBuilder} from '../data/anki-note-builder.js';
-import {isNoteDataValid} from '../data/anki-util.js';
+import {invalidNoteId, 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';
@@ -425,7 +425,11 @@ export class DisplayAnki {
if (Array.isArray(noteIds) && noteIds.length > 0) {
if (allNoteIds === null) { allNoteIds = new Set(); }
- for (const noteId of noteIds) { allNoteIds.add(noteId); }
+ for (const noteId of noteIds) {
+ if (noteId !== invalidNoteId) {
+ allNoteIds.add(noteId);
+ }
+ }
}
if (displayTags !== 'never' && Array.isArray(noteInfos)) {