From afafc55de0e5e892889a625cbf6f087538e5c72c Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 18 Jan 2022 21:30:17 +0900 Subject: [PATCH] wip: refactor(client): migrate components to composition api Fix #8155 --- packages/client/src/account.ts | 9 +- packages/client/src/pages/instance-info.vue | 137 +++++++------------ packages/client/src/scripts/get-user-menu.ts | 4 +- 3 files changed, 57 insertions(+), 93 deletions(-) diff --git a/packages/client/src/account.ts b/packages/client/src/account.ts index 4c83b78c9..76a0d2bd0 100644 --- a/packages/client/src/account.ts +++ b/packages/client/src/account.ts @@ -16,6 +16,8 @@ const data = localStorage.getItem('account'); // TODO: 外部からはreadonlyに export const $i = data ? reactive(JSON.parse(data) as Account) : null; +export const iAmModerator = $i != null && ($i.isAdmin || $i.isModerator); + export async function signout() { waiting(); localStorage.removeItem('account'); @@ -197,10 +199,3 @@ export async function openAccountMenu(ev: MouseEvent) { align: 'left' }); } - -// このファイルに書きたくないけどここに書かないと何故かVeturが認識しない -declare module '@vue/runtime-core' { - interface ComponentCustomProperties { - $i: typeof $i; - } -} diff --git a/packages/client/src/pages/instance-info.vue b/packages/client/src/pages/instance-info.vue index 475107ab6..fa36db065 100644 --- a/packages/client/src/pages/instance-info.vue +++ b/packages/client/src/pages/instance-info.vue @@ -28,7 +28,7 @@ {{ $ts.stopActivityDelivery }} - {{ $ts.blockThisInstance }} + {{ $ts.blockThisInstance }} @@ -104,15 +104,14 @@ - diff --git a/packages/client/src/scripts/get-user-menu.ts b/packages/client/src/scripts/get-user-menu.ts index ebe101bc0..7b910a008 100644 --- a/packages/client/src/scripts/get-user-menu.ts +++ b/packages/client/src/scripts/get-user-menu.ts @@ -5,7 +5,7 @@ import * as Acct from 'misskey-js/built/acct'; import * as os from '@/os'; import { userActions } from '@/store'; import { router } from '@/router'; -import { $i } from '@/account'; +import { $i, iAmModerator } from '@/account'; export function getUserMenu(user) { const meId = $i ? $i.id : null; @@ -175,7 +175,7 @@ export function getUserMenu(user) { action: reportAbuse }]); - if ($i && ($i.isAdmin || $i.isModerator)) { + if (iAmModerator) { menu = menu.concat([null, { icon: 'fas fa-microphone-slash', text: user.isSilenced ? i18n.locale.unsilence : i18n.locale.silence,