Sort deck and model names in Anki card settings (#956)
This commit is contained in:
parent
defd7402cf
commit
92c083ee9f
@ -36,6 +36,7 @@ class AnkiController {
|
|||||||
'clipboard-image',
|
'clipboard-image',
|
||||||
'clipboard-text'
|
'clipboard-text'
|
||||||
]);
|
]);
|
||||||
|
this._stringComparer = new Intl.Collator(); // Locale does not matter
|
||||||
this._ankiOptions = null;
|
this._ankiOptions = null;
|
||||||
this._getAnkiDataPromise = null;
|
this._getAnkiDataPromise = null;
|
||||||
this._ankiErrorContainer = null;
|
this._ankiErrorContainer = null;
|
||||||
@ -210,6 +211,7 @@ class AnkiController {
|
|||||||
async _getDeckNames() {
|
async _getDeckNames() {
|
||||||
try {
|
try {
|
||||||
const result = await this._ankiConnect.getDeckNames();
|
const result = await this._ankiConnect.getDeckNames();
|
||||||
|
this._sortStringArray(result);
|
||||||
return [result, null];
|
return [result, null];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return [[], e];
|
return [[], e];
|
||||||
@ -219,6 +221,7 @@ class AnkiController {
|
|||||||
async _getModelNames() {
|
async _getModelNames() {
|
||||||
try {
|
try {
|
||||||
const result = await this._ankiConnect.getModelNames();
|
const result = await this._ankiConnect.getModelNames();
|
||||||
|
this._sortStringArray(result);
|
||||||
return [result, null];
|
return [result, null];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return [[], e];
|
return [[], e];
|
||||||
@ -270,6 +273,11 @@ class AnkiController {
|
|||||||
}
|
}
|
||||||
return markers;
|
return markers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_sortStringArray(array) {
|
||||||
|
const stringComparer = this._stringComparer;
|
||||||
|
array.sort((a, b) => stringComparer.compare(a, b));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnkiCardController {
|
class AnkiCardController {
|
||||||
|
Loading…
Reference in New Issue
Block a user