From 2f05f4993ccbcc88cd93009183889f32aa84a78d Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Wed, 19 Jun 2024 14:31:17 +0200 Subject: [PATCH] Set case-insensitive sorting as default & Add a user pref to restore legacy behavior - Closes #347 --- config/2fauth.php | 1 + resources/js/stores/twofaccounts.js | 10 ++++++++-- resources/js/views/settings/Options.vue | 6 ++++-- resources/lang/en/settings.php | 4 ++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/config/2fauth.php b/config/2fauth.php index 4cc1f45c..ae678975 100644 --- a/config/2fauth.php +++ b/config/2fauth.php @@ -125,6 +125,7 @@ 'notifyOnNewAuthDevice' => false, 'notifyOnFailedLogin' => false, 'timezone' => env('APP_TIMEZONE', 'UTC'), + 'sortCaseSensitive' => false, ], ]; diff --git a/resources/js/stores/twofaccounts.js b/resources/js/stores/twofaccounts.js index daa29e55..78970322 100644 --- a/resources/js/stores/twofaccounts.js +++ b/resources/js/stores/twofaccounts.js @@ -181,7 +181,10 @@ export const useTwofaccounts = defineStore({ * Sorts accounts ascending */ sortAsc() { - this.items.sort((a, b) => a.service > b.service ? 1 : -1) + 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.saveOrder() }, @@ -189,7 +192,10 @@ export const useTwofaccounts = defineStore({ * Sorts accounts descending */ sortDesc() { - this.items.sort((a, b) => a.service < b.service ? 1 : -1) + 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.saveOrder() }, diff --git a/resources/js/views/settings/Options.vue b/resources/js/views/settings/Options.vue index fcf6ab8e..1564376f 100644 --- a/resources/js/views/settings/Options.vue +++ b/resources/js/views/settings/Options.vue @@ -137,9 +137,11 @@ + - - + + +

{{ $t('groups.groups') }}

diff --git a/resources/lang/en/settings.php b/resources/lang/en/settings.php index 8226d787..3aeb598c 100644 --- a/resources/lang/en/settings.php +++ b/resources/lang/en/settings.php @@ -73,6 +73,10 @@ 'label' => 'Clear Search on copy', 'help' => 'Empty the Search box right after a code has been copied to the clipboard' ], + 'sort_case_sensitive' => [ + 'label' => 'Sort case sensitive', + 'help' => 'When invoked, force the Sort function to sort accounts on a case-sensitive basis' + ], 'copy_otp_on_display' => [ 'label' => 'Copy OTP on display', 'help' => 'Automatically copy a generated password right after it appears on screen. Due to browsers limitations, only the first TOTP password will be copied, not the rotating ones'