mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-04-17 14:08:35 +02:00
Fix accounts sorting - Closes #347
This commit is contained in:
parent
4e463a781b
commit
5d3a1be38f
@ -49,4 +49,8 @@ export function useDisplayablePassword(pwd, reveal = false) {
|
||||
}
|
||||
|
||||
return user.preferences.showOtpAsDot && !reveal ? pwd.replace(/[0-9]/g, '●') : pwd
|
||||
}
|
||||
|
||||
export function startsWithUppercase(str) {
|
||||
return str.substr(0, 1).match(/[A-Z\u00C0-\u00DC]/);
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { startsWithUppercase } from '@/composables/helpers'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useNotifyStore } from '@/stores/notify'
|
||||
import twofaccountService from '@/services/twofaccountService'
|
||||
@ -181,10 +182,16 @@ export const useTwofaccounts = defineStore({
|
||||
* Sorts accounts ascending
|
||||
*/
|
||||
sortAsc() {
|
||||
if (useUserStore().preferences.sortCaseSensitive) {
|
||||
this.items.sort((a, b) => a.service > b.service ? 1 : -1)
|
||||
}
|
||||
else this.items.sort((a, b) => a.service.toLowerCase() > b.service.toLowerCase() ? 1 : -1)
|
||||
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.localeCompare(b.service, useUserStore().preferences.lang)
|
||||
});
|
||||
this.saveOrder()
|
||||
},
|
||||
|
||||
@ -192,10 +199,16 @@ export const useTwofaccounts = defineStore({
|
||||
* Sorts accounts descending
|
||||
*/
|
||||
sortDesc() {
|
||||
if (useUserStore().preferences.sortCaseSensitive) {
|
||||
this.items.sort((a, b) => a.service < b.service ? 1 : -1)
|
||||
}
|
||||
else this.items.sort((a, b) => a.service.toLowerCase() < b.service.toLowerCase() ? 1 : -1)
|
||||
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 b.service.localeCompare(a.service, useUserStore().preferences.lang)
|
||||
});
|
||||
this.saveOrder()
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user