From 1bf6cdce614c1c90ff01513ca1d2fe87bc3c5d90 Mon Sep 17 00:00:00 2001 From: Minneyar <63-minneyar@users.noreply.git.joinfirefish.org> Date: Sun, 22 Oct 2023 21:29:46 +0000 Subject: [PATCH] fix: Extract $i from account.ts into reactiveAccount.ts to fix circular dependency Co-authored-by: minneyar --- packages/client/src/account.ts | 10 ++-------- packages/client/src/components/MkChatPreview.vue | 2 +- packages/client/src/components/MkCropperDialog.vue | 2 +- packages/client/src/components/MkDrive.file.vue | 2 +- packages/client/src/components/MkFollowButton.vue | 2 +- packages/client/src/components/MkHeatmap.vue | 2 +- packages/client/src/components/MkMention.vue | 2 +- packages/client/src/components/MkNote.vue | 2 +- packages/client/src/components/MkNoteDetailed.vue | 2 +- packages/client/src/components/MkNoteSub.vue | 2 +- packages/client/src/components/MkNotifications.vue | 2 +- packages/client/src/components/MkPostForm.vue | 7 ++----- .../src/components/MkPushNotificationAllowButton.vue | 3 ++- packages/client/src/components/MkQuoteButton.vue | 2 +- .../src/components/MkReactionsViewer.reaction.vue | 2 +- packages/client/src/components/MkReactionsViewer.vue | 2 +- packages/client/src/components/MkRenoteButton.vue | 2 +- packages/client/src/components/MkTimeline.vue | 2 +- packages/client/src/components/MkTutorialDialog.vue | 2 +- packages/client/src/components/global/MkPageHeader.vue | 3 ++- packages/client/src/components/page/page.vue | 2 +- packages/client/src/init.ts | 3 ++- packages/client/src/navbar.ts | 2 +- packages/client/src/os.ts | 2 +- packages/client/src/pages/admin/index.vue | 2 +- packages/client/src/pages/auth.vue | 3 ++- packages/client/src/pages/channel.vue | 2 +- packages/client/src/pages/clip.vue | 2 +- packages/client/src/pages/explore.users.vue | 2 +- packages/client/src/pages/follow-requests.vue | 2 +- packages/client/src/pages/messaging/index.vue | 2 +- .../src/pages/messaging/messaging-room.message.vue | 2 +- packages/client/src/pages/messaging/messaging-room.vue | 2 +- packages/client/src/pages/miauth.vue | 3 ++- packages/client/src/pages/page-editor/page-editor.vue | 2 +- packages/client/src/pages/scratchpad.vue | 2 +- packages/client/src/pages/settings/2fa.vue | 2 +- packages/client/src/pages/settings/account-info.vue | 2 +- packages/client/src/pages/settings/accounts.vue | 2 +- packages/client/src/pages/settings/drive.vue | 2 +- packages/client/src/pages/settings/email.vue | 2 +- packages/client/src/pages/settings/general.vue | 2 +- packages/client/src/pages/settings/index.vue | 3 ++- packages/client/src/pages/settings/instance-mute.vue | 2 +- packages/client/src/pages/settings/migration.vue | 2 +- packages/client/src/pages/settings/notifications.vue | 2 +- .../client/src/pages/settings/preferences-backups.vue | 2 +- packages/client/src/pages/settings/privacy.vue | 2 +- packages/client/src/pages/settings/profile.vue | 2 +- packages/client/src/pages/settings/word-mute.vue | 2 +- packages/client/src/pages/theme-editor.vue | 2 +- packages/client/src/pages/timeline.vue | 2 +- packages/client/src/pages/user/home.vue | 2 +- packages/client/src/pages/user/index.vue | 2 +- packages/client/src/pizzax.ts | 2 +- packages/client/src/reactiveAccount.ts | 9 +++++++++ packages/client/src/router.ts | 3 ++- packages/client/src/scripts/aiscript/api.ts | 2 +- packages/client/src/scripts/get-note-menu.ts | 2 +- packages/client/src/scripts/get-user-menu.ts | 3 ++- packages/client/src/scripts/please-login.ts | 2 +- packages/client/src/scripts/upload.ts | 2 +- packages/client/src/scripts/use-note-capture.ts | 2 +- packages/client/src/stream.ts | 2 +- packages/client/src/theme-store.ts | 2 +- packages/client/src/ui/_common_/common.vue | 2 +- packages/client/src/ui/_common_/navbar.vue | 3 ++- packages/client/src/ui/_common_/sw-inject.ts | 3 ++- packages/client/src/ui/deck.vue | 2 +- packages/client/src/ui/deck/tl-column.vue | 2 +- packages/client/src/ui/universal.vue | 2 +- packages/client/src/widgets/activity.vue | 2 +- packages/client/src/widgets/aiscript.vue | 2 +- packages/client/src/widgets/button.vue | 2 +- packages/client/src/widgets/calendar.vue | 2 +- 75 files changed, 95 insertions(+), 85 deletions(-) create mode 100644 packages/client/src/reactiveAccount.ts diff --git a/packages/client/src/account.ts b/packages/client/src/account.ts index d1141986e..f1185e4df 100644 --- a/packages/client/src/account.ts +++ b/packages/client/src/account.ts @@ -6,17 +6,11 @@ import { apiUrl } from "@/config"; import { alert, api, popup, popupMenu, waiting } from "@/os"; import { reloadChannel, unisonReload } from "@/scripts/unison-reload"; import icon from "@/scripts/icon"; +import { $i } from "@/reactiveAccount"; // TODO: 他のタブと永続化されたstateを同期 -type Account = firefish.entities.MeDetailed; - -const accountData = localStorage.getItem("account"); - -// TODO: 外部からはreadonlyに -export const $i = accountData - ? reactive(JSON.parse(accountData) as Account) - : null; +export type Account = firefish.entities.MeDetailed; export const iAmModerator = $i != null && ($i.isAdmin || $i.isModerator); export const iAmAdmin = $i?.isAdmin; diff --git a/packages/client/src/components/MkChatPreview.vue b/packages/client/src/components/MkChatPreview.vue index d4c8dfaa7..27db671bd 100644 --- a/packages/client/src/components/MkChatPreview.vue +++ b/packages/client/src/components/MkChatPreview.vue @@ -66,7 +66,7 @@ import * as Acct from "firefish-js/built/acct"; import { i18n } from "@/i18n"; import { acct } from "@/filters/user"; -import { $i } from "@/account"; +import { $i } from "@/reactiveAccount"; const getAcct = Acct.toString; diff --git a/packages/client/src/components/MkCropperDialog.vue b/packages/client/src/components/MkCropperDialog.vue index c85cdf941..1c5669933 100644 --- a/packages/client/src/components/MkCropperDialog.vue +++ b/packages/client/src/components/MkCropperDialog.vue @@ -42,7 +42,7 @@ import Cropper from "cropperjs"; import tinycolor from "tinycolor2"; import XModalWindow from "@/components/MkModalWindow.vue"; import * as os from "@/os"; -import { $i } from "@/account"; +import { $i } from "@/reactiveAccount"; import { defaultStore } from "@/store"; import { apiUrl, url } from "@/config"; import { query } from "@/scripts/url"; diff --git a/packages/client/src/components/MkDrive.file.vue b/packages/client/src/components/MkDrive.file.vue index 8f5a10730..483375938 100644 --- a/packages/client/src/components/MkDrive.file.vue +++ b/packages/client/src/components/MkDrive.file.vue @@ -45,7 +45,7 @@ import MkDriveFileThumbnail from "@/components/MkDriveFileThumbnail.vue"; import bytes from "@/filters/bytes"; import * as os from "@/os"; import { i18n } from "@/i18n"; -import { $i } from "@/account"; +import { $i } from "@/reactiveAccount"; import icon from "@/scripts/icon"; const props = withDefaults( diff --git a/packages/client/src/components/MkFollowButton.vue b/packages/client/src/components/MkFollowButton.vue index 961805f55..035847480 100644 --- a/packages/client/src/components/MkFollowButton.vue +++ b/packages/client/src/components/MkFollowButton.vue @@ -66,7 +66,7 @@ import type * as firefish from "firefish-js"; import * as os from "@/os"; import { stream } from "@/stream"; import { i18n } from "@/i18n"; -import { $i } from "@/account"; +import { $i } from "@/reactiveAccount"; import { getUserMenu } from "@/scripts/get-user-menu"; import { useRouter } from "@/router"; import { vibrate } from "@/scripts/vibrate"; diff --git a/packages/client/src/components/MkHeatmap.vue b/packages/client/src/components/MkHeatmap.vue index 0565c5914..fb88f995f 100644 --- a/packages/client/src/components/MkHeatmap.vue +++ b/packages/client/src/components/MkHeatmap.vue @@ -15,7 +15,7 @@ import { defaultStore } from "@/store"; import { useChartTooltip } from "@/scripts/use-chart-tooltip"; import { alpha } from "@/scripts/color"; import { initChart } from "@/scripts/init-chart"; -import { $i } from "@/account"; +import { $i } from "@/reactiveAccount"; initChart(); diff --git a/packages/client/src/components/MkMention.vue b/packages/client/src/components/MkMention.vue index fa8e2a871..b113d9cb1 100644 --- a/packages/client/src/components/MkMention.vue +++ b/packages/client/src/components/MkMention.vue @@ -37,7 +37,7 @@ import { toUnicode } from "punycode"; import {} from "vue"; import { host as localHost } from "@/config"; -import { $i } from "@/account"; +import { $i } from "@/reactiveAccount"; import { defaultStore } from "@/store"; const props = defineProps<{ diff --git a/packages/client/src/components/MkNote.vue b/packages/client/src/components/MkNote.vue index 7a63f9012..92584bce0 100644 --- a/packages/client/src/components/MkNote.vue +++ b/packages/client/src/components/MkNote.vue @@ -294,7 +294,7 @@ import { userPage } from "@/filters/user"; import * as os from "@/os"; import { defaultStore, noteViewInterruptors } from "@/store"; import { reactionPicker } from "@/scripts/reaction-picker"; -import { $i } from "@/account"; +import { $i } from "@/reactiveAccount"; import { i18n } from "@/i18n"; import { getNoteMenu } from "@/scripts/get-note-menu"; import { useNoteCapture } from "@/scripts/use-note-capture"; diff --git a/packages/client/src/components/MkNoteDetailed.vue b/packages/client/src/components/MkNoteDetailed.vue index a2e9c10db..97232c518 100644 --- a/packages/client/src/components/MkNoteDetailed.vue +++ b/packages/client/src/components/MkNoteDetailed.vue @@ -182,7 +182,7 @@ import { userPage } from "@/filters/user"; import * as os from "@/os"; import { defaultStore, noteViewInterruptors } from "@/store"; import { reactionPicker } from "@/scripts/reaction-picker"; -import { $i } from "@/account"; +import { $i } from "@/reactiveAccount"; import { i18n } from "@/i18n"; import { getNoteMenu } from "@/scripts/get-note-menu"; import { useNoteCapture } from "@/scripts/use-note-capture"; diff --git a/packages/client/src/components/MkNoteSub.vue b/packages/client/src/components/MkNoteSub.vue index 1dd135170..5bca4e8dc 100644 --- a/packages/client/src/components/MkNoteSub.vue +++ b/packages/client/src/components/MkNoteSub.vue @@ -210,7 +210,7 @@ import { useRouter } from "@/router"; import { userPage } from "@/filters/user"; import * as os from "@/os"; import { reactionPicker } from "@/scripts/reaction-picker"; -import { $i } from "@/account"; +import { $i } from "@/reactiveAccount"; import { i18n } from "@/i18n"; import { useNoteCapture } from "@/scripts/use-note-capture"; import { defaultStore } from "@/store"; diff --git a/packages/client/src/components/MkNotifications.vue b/packages/client/src/components/MkNotifications.vue index e9292342b..8ae736511 100644 --- a/packages/client/src/components/MkNotifications.vue +++ b/packages/client/src/components/MkNotifications.vue @@ -54,7 +54,7 @@ import XNotification from "@/components/MkNotification.vue"; import XList from "@/components/MkDateSeparatedList.vue"; import XNote from "@/components/MkNote.vue"; import { stream } from "@/stream"; -import { $i } from "@/account"; +import { $i } from "@/reactiveAccount"; import { i18n } from "@/i18n"; const props = defineProps<{ diff --git a/packages/client/src/components/MkPostForm.vue b/packages/client/src/components/MkPostForm.vue index fabf44411..a3d7b4666 100644 --- a/packages/client/src/components/MkPostForm.vue +++ b/packages/client/src/components/MkPostForm.vue @@ -268,11 +268,8 @@ import { defaultStore, notePostInterruptors, postFormActions } from "@/store"; import MkInfo from "@/components/MkInfo.vue"; import { i18n } from "@/i18n"; import { instance } from "@/instance"; -import { - $i, - getAccounts, - openAccountMenu as openAccountMenu_, -} from "@/account"; +import { getAccounts, openAccountMenu as openAccountMenu_ } from "@/account"; +import { $i } from "@/reactiveAccount"; import { uploadFile } from "@/scripts/upload"; import { deepClone } from "@/scripts/clone"; import XCheatSheet from "@/components/MkCheatSheetDialog.vue"; diff --git a/packages/client/src/components/MkPushNotificationAllowButton.vue b/packages/client/src/components/MkPushNotificationAllowButton.vue index 37ba5ceef..575983e3b 100644 --- a/packages/client/src/components/MkPushNotificationAllowButton.vue +++ b/packages/client/src/components/MkPushNotificationAllowButton.vue @@ -55,7 +55,8 @@