diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c28003..6fca586 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- Possibility to set a default account + ### Changed - The style has been entirely reworked using Bootstrap instead of Bulma - It is now impossible to include the separator in the dedicated name diff --git a/src/accounts.js b/src/accounts.js index 93d0bc3..80b9d25 100644 --- a/src/accounts.js +++ b/src/accounts.js @@ -1,5 +1,5 @@ export function sortAccounts(accounts) { - accounts.value.sort((a, b) => { + accounts.sort((a, b) => { const va = `${a.localPart}@${a.domain}`; const vb = `${b.localPart}@${b.domain}`; return va.localeCompare(vb); diff --git a/src/locales/en.json b/src/locales/en.json index c4e29df..bf89aee 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -71,6 +71,8 @@ }, "manageAccounts": { "title": "Accounts", + "isDefault": "default", + "setDefault": "Set default", "delete": "@:invariants.controls.delete", "close": "@:invariants.controls.close" } diff --git a/src/locales/fr.json b/src/locales/fr.json index 4130474..6cccfea 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -71,6 +71,8 @@ }, "manageAccounts": { "title": "Comptes", + "isDefault": "défaut", + "setDefault": "Définir par défaut", "delete": "@:invariants.controls.delete", "close": "@:invariants.controls.close" } diff --git a/src/views/AddAccountView.vue b/src/views/AddAccountView.vue index f2760c5..7bc3531 100644 --- a/src/views/AddAccountView.vue +++ b/src/views/AddAccountView.vue @@ -62,6 +62,7 @@ const addAccount = () => { separator: separator.value, domain: domainName.value, key: key, + isDefault: false, }; accounts.value.push(newAccount); return toMainView(); diff --git a/src/views/MainView.vue b/src/views/MainView.vue index 2b106d7..a1f83db 100644 --- a/src/views/MainView.vue +++ b/src/views/MainView.vue @@ -11,8 +11,12 @@ import LayoutComponent from '../components/LayoutComponent.vue'; import NavBarComponent from '../components/NavBarComponent.vue'; const router = useRouter(); -const accounts = sortAccounts(useStorage('sake-accounts', [])); -const selectedAccountId = ref(accounts.value[0].id); +const accounts = useStorage('sake-accounts', []); +const sortedAccounts = computed(() => sortAccounts(accounts.value)); +const selectedAccountId = ref((() => { + const def = accounts.value.find((a) => a.isDefault); + return def ? def.id : accounts.value[0].id; +})()); const subAddrName = ref(''); const fromRawAccount = (raw_account) => { @@ -63,7 +67,7 @@ const resetForm = () => {