summaryrefslogtreecommitdiff
path: root/ext/js/background
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-02-24 22:23:40 -0500
committerGitHub <noreply@github.com>2021-02-24 22:23:40 -0500
commit6bda81b4220cf6057f24e5b08aa9a62e4e535bc2 (patch)
tree62a73f8270e0e044f18f8a1d395fec7e86573154 /ext/js/background
parentae92e0b3781e27d54cbac2570ba2a1b8a6b11999 (diff)
Improve note addability (#1440)
* Add valid field * Add isNoteDataValid function * Update _areDefinitionsAddableForcedValue to return proper valid values * Refactor isAnkiConnected check * Force canAdd to false if not valid
Diffstat (limited to 'ext/js/background')
-rw-r--r--ext/js/background/backend.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index 323219a4..f04006bc 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -17,6 +17,7 @@
/* global
* AnkiConnect
+ * AnkiUtil
* AudioDownloader
* ClipboardMonitor
* ClipboardReader
@@ -456,10 +457,12 @@ class Backend {
for (let i = 0; i < notes.length; ++i) {
const note = notes[i];
- const canAdd = canAddArray[i];
- const info = {canAdd, noteIds: null};
+ let canAdd = canAddArray[i];
+ const valid = AnkiUtil.isNoteDataValid(note);
+ if (!valid) { canAdd = false; }
+ const info = {canAdd, valid, noteIds: null};
results.push(info);
- if (!canAdd) {
+ if (!canAdd && valid) {
cannotAdd.push({note, info});
}
}