aboutsummaryrefslogtreecommitdiff
path: root/ext/js/pages
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2022-02-20 09:35:54 -0500
committerGitHub <noreply@github.com>2022-02-20 09:35:54 -0500
commit48b2807120928654ae52ea78bd7d2d9824eaa05e (patch)
tree9732815074e7343fa38f8a6e91f7d8af9ab72b58 /ext/js/pages
parent045eb63a52697b4436c935d4db1716762fef5eb8 (diff)
Add support for logging Anki errors on the settings page (#2073)
Diffstat (limited to 'ext/js/pages')
-rw-r--r--ext/js/pages/settings/anki-controller.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/js/pages/settings/anki-controller.js b/ext/js/pages/settings/anki-controller.js
index a99f0f33..a7630d86 100644
--- a/ext/js/pages/settings/anki-controller.js
+++ b/ext/js/pages/settings/anki-controller.js
@@ -43,6 +43,7 @@ class AnkiController {
this._ankiErrorMessageDetailsToggle = null;
this._ankiErrorInvalidResponseInfo = null;
this._ankiCardPrimary = null;
+ this._ankiError = null;
this._validateFieldsToken = null;
}
@@ -70,6 +71,8 @@ class AnkiController {
input.addEventListener('change', this._onAnkiCardPrimaryTypeRadioChange.bind(this), false);
}
+ document.querySelector('#anki-error-log').addEventListener('click', this._onAnkiErrorLogLinkClick.bind(this));
+
const options = await this._settingsController.getOptions();
this._settingsController.on('optionsChanged', this._onOptionsChanged.bind(this));
this._onOptionsChanged({options});
@@ -184,6 +187,11 @@ class AnkiController {
this._setAnkiCardPrimaryType(node.dataset.value, node.dataset.ankiCardMenu);
}
+ _onAnkiErrorLogLinkClick() {
+ if (this._ankiError === null) { return; }
+ console.log({error: this._ankiError});
+ }
+
_setAnkiCardPrimaryType(ankiCardType, ankiCardMenu) {
if (this._ankiCardPrimary === null) { return; }
this._ankiCardPrimary.dataset.ankiCardType = ankiCardType;
@@ -296,9 +304,12 @@ class AnkiController {
this._ankiErrorMessageNode.textContent = (this._ankiConnect.enabled ? 'Connected' : 'Not enabled');
this._ankiErrorMessageNode.classList.remove('danger-text');
this._ankiErrorMessageDetailsNode.textContent = '';
+ this._ankiError = null;
}
_showAnkiError(error) {
+ this._ankiError = error;
+
let errorString = typeof error === 'object' && error !== null ? error.message : null;
if (!errorString) { errorString = `${error}`; }
if (!/[.!?]$/.test(errorString)) { errorString += '.'; }