From b718a29921d6c7a086467b8f5bc5c6e26ee91395 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 27 May 2025 19:03:21 +0800 Subject: [PATCH] Allow arrange accounts --- src/components/ICONS.jsx | 1 + src/locales/en.po | 34 ++++++++++------- src/pages/accounts.jsx | 81 ++++++++++++++++++++++++++++++++-------- 3 files changed, 87 insertions(+), 29 deletions(-) diff --git a/src/components/ICONS.jsx b/src/components/ICONS.jsx index c3a21dd4..3a3823c2 100644 --- a/src/components/ICONS.jsx +++ b/src/components/ICONS.jsx @@ -16,6 +16,7 @@ export const ICONS = { }, 'arrow-up': () => import('@iconify-icons/mingcute/arrow-up-line'), 'arrow-down': () => import('@iconify-icons/mingcute/arrow-down-line'), + 'arrow-to-up-line': () => import('@iconify-icons/mingcute/arrow-to-up-line'), earth: () => import('@iconify-icons/mingcute/earth-line'), lock: () => import('@iconify-icons/mingcute/lock-line'), unlock: () => import('@iconify-icons/mingcute/unlock-line'), diff --git a/src/locales/en.po b/src/locales/en.po index a9aade16..13ce3fd9 100644 --- a/src/locales/en.po +++ b/src/locales/en.po @@ -117,7 +117,7 @@ msgstr "" #: src/components/status.jsx:2598 #: src/components/status.jsx:2601 #: src/pages/account-statuses.jsx:526 -#: src/pages/accounts.jsx:113 +#: src/pages/accounts.jsx:114 #: src/pages/hashtag.jsx:202 #: src/pages/list.jsx:171 #: src/pages/public.jsx:116 @@ -469,7 +469,7 @@ msgstr "" #: src/components/status.jsx:3100 #: src/components/status.jsx:3340 #: src/components/status.jsx:3849 -#: src/pages/accounts.jsx:40 +#: src/pages/accounts.jsx:41 #: src/pages/catchup.jsx:1584 #: src/pages/filters.jsx:225 #: src/pages/list.jsx:302 @@ -1076,7 +1076,7 @@ msgstr "" #: src/components/generic-accounts.jsx:154 #: src/components/notification.jsx:449 -#: src/pages/accounts.jsx:45 +#: src/pages/accounts.jsx:46 #: src/pages/search.jsx:334 #: src/pages/search.jsx:367 msgid "Accounts" @@ -1983,10 +1983,12 @@ msgid "Not available in current view mode" msgstr "" #: src/components/shortcuts-settings.jsx:351 +#: src/pages/accounts.jsx:201 msgid "Move up" msgstr "" #: src/components/shortcuts-settings.jsx:367 +#: src/pages/accounts.jsx:216 msgid "Move down" msgstr "" @@ -2688,49 +2690,53 @@ msgstr "" msgid "Month" msgstr "" -#: src/pages/accounts.jsx:59 +#: src/pages/accounts.jsx:60 msgid "Current" msgstr "" -#: src/pages/accounts.jsx:105 +#: src/pages/accounts.jsx:106 msgid "Default" msgstr "" -#: src/pages/accounts.jsx:127 +#: src/pages/accounts.jsx:128 msgid "Switch to this account" msgstr "Switch to this account" -#: src/pages/accounts.jsx:136 +#: src/pages/accounts.jsx:137 msgid "Switch in new tab/window" msgstr "Switch in new tab/window" -#: src/pages/accounts.jsx:150 +#: src/pages/accounts.jsx:151 msgid "View profile…" msgstr "" -#: src/pages/accounts.jsx:167 +#: src/pages/accounts.jsx:169 msgid "Set as default" msgstr "" +#: src/pages/accounts.jsx:185 +msgid "Move to top" +msgstr "Move to top" + #. placeholder {0}: account.info.acct -#: src/pages/accounts.jsx:177 +#: src/pages/accounts.jsx:228 msgid "Log out <0>@{0}?" msgstr "" -#: src/pages/accounts.jsx:206 +#: src/pages/accounts.jsx:257 msgid "Log out…" msgstr "" #. placeholder {0}: niceDateTime(account.createdAt) -#: src/pages/accounts.jsx:213 +#: src/pages/accounts.jsx:264 msgid "Connected on {0} (<0/>)" msgstr "Connected on {0} (<0/>)" -#: src/pages/accounts.jsx:230 +#: src/pages/accounts.jsx:281 msgid "Add an existing account" msgstr "" -#: src/pages/accounts.jsx:237 +#: src/pages/accounts.jsx:288 msgid "Note: <0>Default account will always be used for first load. Switched accounts will persist during the session." msgstr "" diff --git a/src/pages/accounts.jsx b/src/pages/accounts.jsx index 55f87494..018eb01c 100644 --- a/src/pages/accounts.jsx +++ b/src/pages/accounts.jsx @@ -29,6 +29,7 @@ function Accounts({ onClose }) { const accounts = store.local.getJSON('accounts'); const currentAccount = getCurrentAccountID(); const moreThanOneAccount = accounts.length > 1; + const moreThanThreeAccounts = accounts.length > 3; const [_, reload] = useReducer((x) => x + 1, 0); const [accountsListParent] = useAutoAnimate(); @@ -152,21 +153,71 @@ function Accounts({ onClose }) { {moreThanOneAccount && ( - { - // Move account to the top of the list - accounts.splice(i, 1); - accounts.unshift(account); - store.local.setJSON('accounts', accounts); - reload(); - }} - > - - - Set as default - - + <> + { + // Move account to the top of the list + accounts.splice(i, 1); + accounts.unshift(account); + store.local.setJSON('accounts', accounts); + reload(); + }} + > + + + Set as default + + + {moreThanThreeAccounts && ( + { + // Move account to position 1 (right below default) + accounts.splice(i, 1); + accounts.splice(1, 0, account); + store.local.setJSON('accounts', accounts); + reload(); + }} + > + + + Move to top + + + )} + { + // Move account one position up + accounts.splice(i, 1); + accounts.splice(i - 1, 0, account); + store.local.setJSON('accounts', accounts); + reload(); + }} + > + + + Move up + + + { + // Move account one position down + accounts.splice(i, 1); + accounts.splice(i + 1, 0, account); + store.local.setJSON('accounts', accounts); + reload(); + }} + > + + + Move down + + + + )}