aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/options-form.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-10-19 09:26:26 -0700
committerAlex Yatskov <alex@foosoft.net>2016-10-19 09:26:26 -0700
commitdb918d36754529933ae4896032146755675b891a (patch)
tree20bdc30b39ce4a57cffd2161091799ebd06365aa /ext/bg/js/options-form.js
parent7d93587acb250266782e3788894a9e26ddf1eaa5 (diff)
Relog when ankiweb auth settings change
Diffstat (limited to 'ext/bg/js/options-form.js')
-rw-r--r--ext/bg/js/options-form.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js
index 170b1e8c..fdaf059f 100644
--- a/ext/bg/js/options-form.js
+++ b/ext/bg/js/options-form.js
@@ -198,12 +198,15 @@ function onOptionsChanged(e) {
yomichan().setOptions(optsNew);
updateVisibility(optsNew);
- const invalidated =
- optsNew.ankiMethod !== optsOld.ankiMethod ||
+ const loginChanged =
optsNew.ankiUsername !== optsOld.ankiUsername ||
optsNew.ankiPassword !== optsOld.ankiPassword;
- if (invalidated) {
+ if (loginChanged && optsNew.ankiMethod === 'ankiweb') {
+ anki().logout().then(() => populateAnkiDeckAndModel(optsNew)).catch(error => {
+ $('#anki-error').show().find('span').text(error);
+ });
+ } else if (loginChanged || optsNew.ankiMethod !== optsOld.ankiMethod) {
populateAnkiDeckAndModel(optsNew);
}
});