Allow arrange accounts

pull/1176/head
Lim Chee Aun 2025-05-27 19:03:21 +08:00
rodzic 3ba97ad414
commit b718a29921
3 zmienionych plików z 87 dodań i 29 usunięć

Wyświetl plik

@ -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'),

34
src/locales/en.po wygenerowano
Wyświetl plik

@ -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}</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</0> account will always be used for first load. Switched accounts will persist during the session."
msgstr ""

Wyświetl plik

@ -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 }) {
</MenuItem>
<MenuDivider />
{moreThanOneAccount && (
<MenuItem
disabled={isDefault}
onClick={() => {
// Move account to the top of the list
accounts.splice(i, 1);
accounts.unshift(account);
store.local.setJSON('accounts', accounts);
reload();
}}
>
<Icon icon="check-circle" />
<span>
<Trans>Set as default</Trans>
</span>
</MenuItem>
<>
<MenuItem
disabled={isDefault}
onClick={() => {
// Move account to the top of the list
accounts.splice(i, 1);
accounts.unshift(account);
store.local.setJSON('accounts', accounts);
reload();
}}
>
<Icon icon="check-circle" />
<span>
<Trans>Set as default</Trans>
</span>
</MenuItem>
{moreThanThreeAccounts && (
<MenuItem
disabled={i <= 2}
onClick={() => {
// Move account to position 1 (right below default)
accounts.splice(i, 1);
accounts.splice(1, 0, account);
store.local.setJSON('accounts', accounts);
reload();
}}
>
<Icon icon="arrow-to-up-line" />
<span>
<Trans>Move to top</Trans>
</span>
</MenuItem>
)}
<MenuItem
disabled={i <= 1}
onClick={() => {
// Move account one position up
accounts.splice(i, 1);
accounts.splice(i - 1, 0, account);
store.local.setJSON('accounts', accounts);
reload();
}}
>
<Icon icon="arrow-up" />
<span>
<Trans>Move up</Trans>
</span>
</MenuItem>
<MenuItem
disabled={i === 0 || i === accounts.length - 1}
onClick={() => {
// Move account one position down
accounts.splice(i, 1);
accounts.splice(i + 1, 0, account);
store.local.setJSON('accounts', accounts);
reload();
}}
>
<Icon icon="arrow-down" />
<span>
<Trans>Move down</Trans>
</span>
</MenuItem>
<MenuDivider />
</>
)}
<MenuConfirm
subMenu