aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/anki-controller.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-10-25 19:04:59 -0400
committerGitHub <noreply@github.com>2020-10-25 19:04:59 -0400
commit92c083ee9ffd4e4d24372c0d74bac7a59621d376 (patch)
tree62e1f173333063fe9c0800d32882f41c55b880a7 /ext/bg/js/settings/anki-controller.js
parentdefd7402cffcfb45d85a56b1f093c91d4fd6e866 (diff)
Sort deck and model names in Anki card settings (#956)
Diffstat (limited to 'ext/bg/js/settings/anki-controller.js')
-rw-r--r--ext/bg/js/settings/anki-controller.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/bg/js/settings/anki-controller.js b/ext/bg/js/settings/anki-controller.js
index e7ee2074..8e4486cd 100644
--- a/ext/bg/js/settings/anki-controller.js
+++ b/ext/bg/js/settings/anki-controller.js
@@ -36,6 +36,7 @@ class AnkiController {
'clipboard-image',
'clipboard-text'
]);
+ this._stringComparer = new Intl.Collator(); // Locale does not matter
this._ankiOptions = null;
this._getAnkiDataPromise = null;
this._ankiErrorContainer = null;
@@ -210,6 +211,7 @@ class AnkiController {
async _getDeckNames() {
try {
const result = await this._ankiConnect.getDeckNames();
+ this._sortStringArray(result);
return [result, null];
} catch (e) {
return [[], e];
@@ -219,6 +221,7 @@ class AnkiController {
async _getModelNames() {
try {
const result = await this._ankiConnect.getModelNames();
+ this._sortStringArray(result);
return [result, null];
} catch (e) {
return [[], e];
@@ -270,6 +273,11 @@ class AnkiController {
}
return markers;
}
+
+ _sortStringArray(array) {
+ const stringComparer = this._stringComparer;
+ array.sort((a, b) => stringComparer.compare(a, b));
+ }
}
class AnkiCardController {