Skip to content

Commit

Permalink
Fix accounts sorting - Fixes #347
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubka committed Sep 9, 2024
1 parent 7c31985 commit d90ffd5
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions resources/js/stores/twofaccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,12 @@ export const useTwofaccounts = defineStore({
sortAsc() {
this.items.sort(function(a, b) {
if (useUserStore().preferences.sortCaseSensitive) {
if (startsWithUppercase(a.service) && !startsWithUppercase(b.service)) {
return -1;
} else if (startsWithUppercase(b.service) && !startsWithUppercase(a.service)) {
return 1;
}
return a.service.normalize("NFD").replace(/[\u0300-\u036f]/g, "") > b.service.normalize("NFD").replace(/[\u0300-\u036f]/g, "") ? 1 : -1
}

return a.service.localeCompare(b.service, useUserStore().preferences.lang)
});

this.saveOrder()
},

Expand All @@ -201,14 +199,12 @@ export const useTwofaccounts = defineStore({
sortDesc() {
this.items.sort(function(a, b) {
if (useUserStore().preferences.sortCaseSensitive) {
if (startsWithUppercase(a.service) && !startsWithUppercase(b.service)) {
return 1;
} else if (startsWithUppercase(b.service) && !startsWithUppercase(a.service)) {
return -1;
}
return a.service.normalize("NFD").replace(/[\u0300-\u036f]/g, "") < b.service.normalize("NFD").replace(/[\u0300-\u036f]/g, "") ? 1 : -1
}

return b.service.localeCompare(a.service, useUserStore().preferences.lang)
});

this.saveOrder()
},

Expand Down

0 comments on commit d90ffd5

Please sign in to comment.