From a7c402fd2f989bea8f7534693a9caad80bde8cab Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 20 Jul 2023 09:03:56 +0000 Subject: [PATCH] feat: ability to replace chat button with account menu on mobile (close #9) --- README.md | 2 + locales/en-US.yml | 2 + locales/ja-JP.yml | 2 + packages/client/src/account.ts | 99 ++++++++++++------- .../client/src/pages/settings/general.vue | 15 +++ packages/client/src/store.ts | 4 + packages/client/src/ui/universal.vue | 27 ++++- 7 files changed, 112 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index ef562022d..4775c6af4 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ ## 主要な変更点 +- モバイル表示の下部のチャットボタンをアカウント切り替えボタンに変更可能に + - これ無しで PWA で複数アカウントを使おうとすると腱鞘炎になる - ローカルタイムラインの位置をグローバルタイムラインの直前に移動 - ローカルタイムラインよりもソーシャルタイムラインのほうが使いやすいと考えたため - 「Firefish について」のページに Misskey の主要な貢献者を表示 diff --git a/locales/en-US.yml b/locales/en-US.yml index 6ca3a1b05..afc4809e0 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -1129,6 +1129,8 @@ showPreviewByDefault: "Show preview in posting form by default" originalFeature: "original" preventMisclick: "Accidental click prevention" hideFollowButtons: "Hide follow buttons in notifications and user pages" +forMobile: "Mobile" +replaceChatButtonWithAccountButton: "Replace chat button at the bottom with account switch button" _sensitiveMediaDetection: description: "Reduces the effort of server moderation through automatically recognizing diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index aa5e380f1..37156d044 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -989,6 +989,8 @@ showPreviewByDefault: "投稿画面でプレビュー表示をデフォルトで originalFeature: "独自機能" preventMisclick: "誤タップ防止" hideFollowButtons: "新規フォロワーの通知とユーザーページの ... の隣にあるフォローボタンを隠す" +forMobile: "モバイル向け" +replaceChatButtonWithAccountButton: "画面下部のチャットのボタンをアカウント切り替えボタンに変更する" _sensitiveMediaDetection: description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てられます。サーバーの負荷が少し増えます。" diff --git a/packages/client/src/account.ts b/packages/client/src/account.ts index b2d6df033..9f48eff8c 100644 --- a/packages/client/src/account.ts +++ b/packages/client/src/account.ts @@ -154,6 +154,7 @@ export async function openAccountMenu( onChoose?: (account: misskey.entities.UserDetailed) => void; }, ev: MouseEvent, + isMobile?: boolean, ) { function showSigninDialog() { popup( @@ -230,48 +231,70 @@ export async function openAccountMenu( popupMenu( [ ...[ - { - type: "link", - text: i18n.ts.profile, - to: `/@${$i.username}`, - avatar: $i, - }, - null, + ...(isMobile ?? false + ? [ + { + type: "parent", + icon: "ph-plus ph-bold ph-lg", + text: i18n.ts.addAccount, + children: [ + { + text: i18n.ts.existingAccount, + action: () => { + showSigninDialog(); + }, + }, + { + text: i18n.ts.createAccount, + action: () => { + createAccount(); + }, + }, + ], + }, + ] + : [ + { + type: "link", + text: i18n.ts.profile, + to: `/@${$i.username}`, + avatar: $i, + }, + null, + ]), ...(opts.includeCurrentAccount ? [createItem($i)] : []), ...accountItemPromises, - { - type: "parent", - icon: "ph-plus ph-bold ph-lg", - text: i18n.ts.addAccount, - children: [ - { - text: i18n.ts.existingAccount, - action: () => { - showSigninDialog(); + ...(isMobile ?? false + ? [ + null, + { + type: "link", + text: i18n.ts.profile, + to: `/@${$i.username}`, + avatar: $i, }, - }, - { - text: i18n.ts.createAccount, - action: () => { - createAccount(); + ] + : [ + { + type: "parent", + icon: "ph-plus ph-bold ph-lg", + text: i18n.ts.addAccount, + children: [ + { + text: i18n.ts.existingAccount, + action: () => { + showSigninDialog(); + }, + }, + { + text: i18n.ts.createAccount, + action: () => { + createAccount(); + }, + }, + ], }, - }, - ], - }, - { - type: "link", - icon: "ph-users ph-bold ph-lg", - text: i18n.ts.manageAccounts, - to: "/settings/accounts", - }, - { - type: "button", - icon: "ph-sign-out ph-bold ph-lg", - text: i18n.ts.logout, - action: () => { - signout(); - }, - }, + ]), ], ], ev.currentTarget ?? ev.target, diff --git a/packages/client/src/pages/settings/general.vue b/packages/client/src/pages/settings/general.vue index 1015fe967..4a6a4ca80 100644 --- a/packages/client/src/pages/settings/general.vue +++ b/packages/client/src/pages/settings/general.vue @@ -238,6 +238,18 @@ > + + + {{ i18n.ts.replaceChatButtonWithAccountButton + }}{{ + i18n.ts.originalFeature + }} + + { defaultStore.set("swipeOnMobile", true); diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index 89709e4ff..2d19bcadc 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -350,6 +350,10 @@ export const defaultStore = markRaw( where: "device", default: true, }, + replaceChatButtonWithAccountButton: { + where: "device", + default: true, + }, }), ); diff --git a/packages/client/src/ui/universal.vue b/packages/client/src/ui/universal.vue index 5fca26489..a744082e5 100644 --- a/packages/client/src/ui/universal.vue +++ b/packages/client/src/ui/universal.vue @@ -86,6 +86,20 @@ +