From fa9c4a19b98167c7552bec8f4d791bd89db8fbbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8A=E3=81=95=E3=82=80=E3=81=AE=E3=81=B2=E3=81=A8?= <46447427+samunohito@users.noreply.github.com> Date: Thu, 4 Jan 2024 18:32:46 +0900 Subject: [PATCH] =?UTF-8?q?refactor(frontend):=20os.ts=E3=81=AB=E5=BC=95?= =?UTF-8?q?=E3=81=8D=E8=BE=BC=E3=82=93=E3=81=A0scripts/api.ts=E3=81=AE?= =?UTF-8?q?=E5=86=8Dexport=E3=82=92=E3=82=84=E3=82=81=E3=82=8B=20(#12694)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(frontend): os.tsに引き込んだscripts/api.tsの再exportをやめる * fix * fix * renate to "misskeyApi" * rename file --- packages/frontend/src/account.ts | 5 ++- packages/frontend/src/cache.ts | 10 ++--- .../src/components/MkAccountMoved.vue | 4 +- .../src/components/MkAchievements.vue | 3 +- .../src/components/MkAnnouncementDialog.vue | 3 +- .../src/components/MkAutocomplete.vue | 5 ++- .../frontend/src/components/MkAvatars.vue | 4 +- .../src/components/MkChannelFollowButton.vue | 6 +-- packages/frontend/src/components/MkChart.vue | 40 +++++++++---------- .../src/components/MkDrive.folder.vue | 9 +++-- .../src/components/MkDrive.navFolder.vue | 6 +-- packages/frontend/src/components/MkDrive.vue | 23 ++++++----- .../src/components/MkFeaturedPhotos.vue | 4 +- .../src/components/MkFollowButton.vue | 11 ++--- .../frontend/src/components/MkHeatmap.vue | 12 +++--- .../src/components/MkInstanceCardMini.vue | 4 +- .../src/components/MkInstanceStats.vue | 3 +- packages/frontend/src/components/MkNote.vue | 15 +++---- .../src/components/MkNoteDetailed.vue | 17 ++++---- .../frontend/src/components/MkNoteSub.vue | 4 +- .../src/components/MkNotification.vue | 6 +-- .../frontend/src/components/MkPagination.vue | 7 ++-- packages/frontend/src/components/MkPoll.vue | 3 +- .../frontend/src/components/MkPostForm.vue | 9 +++-- .../src/components/MkPostFormAttaches.vue | 7 ++-- .../MkPushNotificationAllowButton.vue | 7 ++-- .../components/MkReactionsViewer.reaction.vue | 9 +++-- .../src/components/MkRetentionHeatmap.vue | 4 +- .../src/components/MkRetentionLineChart.vue | 4 +- packages/frontend/src/components/MkSignin.vue | 9 +++-- .../src/components/MkSignupDialog.form.vue | 9 +++-- .../MkUserAnnouncementEditDialog.vue | 3 +- .../src/components/MkUserCardMini.vue | 4 +- .../frontend/src/components/MkUserPopup.vue | 3 +- .../src/components/MkUserSelectDialog.vue | 6 +-- .../components/MkUserSetupDialog.Privacy.vue | 4 +- .../src/components/MkUserSetupDialog.User.vue | 4 +- .../MkVisitorDashboard.ActiveUsersChart.vue | 4 +- .../src/components/MkVisitorDashboard.vue | 5 ++- .../src/components/page/page.note.vue | 4 +- packages/frontend/src/custom-emojis.ts | 6 +-- packages/frontend/src/instance.ts | 4 +- packages/frontend/src/os.ts | 9 ++--- packages/frontend/src/pages/_error_.vue | 4 +- packages/frontend/src/pages/about.vue | 4 +- packages/frontend/src/pages/admin-file.vue | 7 ++-- packages/frontend/src/pages/admin-user.vue | 23 ++++++----- packages/frontend/src/pages/admin/ads.vue | 11 ++--- .../src/pages/admin/announcements.vue | 9 +++-- .../src/pages/admin/bot-protection.vue | 3 +- .../frontend/src/pages/admin/branding.vue | 3 +- .../frontend/src/pages/admin/database.vue | 4 +- .../src/pages/admin/email-settings.vue | 3 +- .../src/pages/admin/external-services.vue | 3 +- packages/frontend/src/pages/admin/files.vue | 3 +- packages/frontend/src/pages/admin/index.vue | 5 ++- .../src/pages/admin/instance-block.vue | 3 +- packages/frontend/src/pages/admin/invites.vue | 7 ++-- .../frontend/src/pages/admin/moderation.vue | 3 +- .../src/pages/admin/object-storage.vue | 3 +- .../src/pages/admin/other-settings.vue | 3 +- .../src/pages/admin/overview.active-users.vue | 4 +- .../src/pages/admin/overview.ap-requests.vue | 4 +- .../src/pages/admin/overview.federation.vue | 5 ++- .../src/pages/admin/overview.instances.vue | 4 +- .../src/pages/admin/overview.moderators.vue | 4 +- .../src/pages/admin/overview.stats.vue | 10 ++--- .../src/pages/admin/overview.users.vue | 4 +- .../frontend/src/pages/admin/overview.vue | 11 ++--- .../src/pages/admin/proxy-account.vue | 5 ++- .../frontend/src/pages/admin/queue.chart.vue | 4 +- packages/frontend/src/pages/admin/relays.vue | 7 ++-- .../frontend/src/pages/admin/roles.edit.vue | 3 +- .../frontend/src/pages/admin/roles.role.vue | 3 +- packages/frontend/src/pages/admin/roles.vue | 3 +- .../frontend/src/pages/admin/security.vue | 3 +- .../frontend/src/pages/admin/settings.vue | 3 +- packages/frontend/src/pages/announcements.vue | 3 +- .../frontend/src/pages/antenna-timeline.vue | 3 +- packages/frontend/src/pages/api-console.vue | 8 ++-- packages/frontend/src/pages/auth.form.vue | 6 +-- packages/frontend/src/pages/auth.vue | 6 +-- .../frontend/src/pages/avatar-decorations.vue | 5 ++- .../frontend/src/pages/channel-editor.vue | 7 ++-- packages/frontend/src/pages/channel.vue | 3 +- packages/frontend/src/pages/clip.vue | 3 +- .../src/pages/custom-emojis-manager.vue | 5 ++- .../frontend/src/pages/drive.file.info.vue | 3 +- .../frontend/src/pages/emoji-edit-dialog.vue | 7 ++-- packages/frontend/src/pages/emojis.emoji.vue | 3 +- packages/frontend/src/pages/explore.roles.vue | 4 +- packages/frontend/src/pages/explore.users.vue | 6 +-- .../frontend/src/pages/flash/flash-edit.vue | 3 +- packages/frontend/src/pages/flash/flash.vue | 3 +- .../frontend/src/pages/follow-requests.vue | 6 +-- packages/frontend/src/pages/follow.vue | 7 ++-- packages/frontend/src/pages/gallery/edit.vue | 3 +- packages/frontend/src/pages/gallery/post.vue | 3 +- .../frontend/src/pages/install-extentions.vue | 3 +- packages/frontend/src/pages/instance-info.vue | 13 +++--- packages/frontend/src/pages/invite.vue | 5 ++- packages/frontend/src/pages/list.vue | 5 ++- packages/frontend/src/pages/miauth.vue | 4 +- .../frontend/src/pages/my-antennas/edit.vue | 4 +- .../frontend/src/pages/my-antennas/editor.vue | 5 ++- .../frontend/src/pages/my-clips/index.vue | 3 +- packages/frontend/src/pages/my-lists/list.vue | 7 ++-- packages/frontend/src/pages/note.vue | 6 +-- .../page-editor/els/page-editor.el.image.vue | 3 +- .../page-editor/els/page-editor.el.note.vue | 4 +- .../src/pages/page-editor/page-editor.vue | 15 +++---- packages/frontend/src/pages/page.vue | 3 +- packages/frontend/src/pages/registry.keys.vue | 3 +- .../frontend/src/pages/registry.value.vue | 3 +- packages/frontend/src/pages/registry.vue | 3 +- packages/frontend/src/pages/role.vue | 4 +- packages/frontend/src/pages/search.note.vue | 3 +- packages/frontend/src/pages/search.user.vue | 3 +- .../frontend/src/pages/settings/accounts.vue | 3 +- packages/frontend/src/pages/settings/api.vue | 3 +- packages/frontend/src/pages/settings/apps.vue | 4 +- .../src/pages/settings/avatar-decoration.vue | 3 +- .../src/pages/settings/drive-cleaner.vue | 3 +- .../frontend/src/pages/settings/drive.vue | 9 +++-- .../frontend/src/pages/settings/email.vue | 5 ++- .../frontend/src/pages/settings/general.vue | 3 +- .../src/pages/settings/import-export.vue | 25 ++++++------ .../frontend/src/pages/settings/migration.vue | 5 ++- .../settings/mute-block.instance-mute.vue | 4 +- .../src/pages/settings/mute-block.vue | 5 ++- .../src/pages/settings/notifications.vue | 5 ++- .../frontend/src/pages/settings/other.vue | 3 +- .../pages/settings/preferences-backups.vue | 3 +- .../frontend/src/pages/settings/privacy.vue | 4 +- .../frontend/src/pages/settings/security.vue | 3 +- .../src/pages/settings/sounds.sound.vue | 3 +- .../frontend/src/pages/settings/statusbar.vue | 4 +- .../src/pages/settings/webhook.edit.vue | 3 +- packages/frontend/src/pages/share.vue | 13 +++--- .../frontend/src/pages/signup-complete.vue | 3 +- packages/frontend/src/pages/timeline.vue | 3 +- .../frontend/src/pages/user-list-timeline.vue | 4 +- .../src/pages/user/activity.following.vue | 4 +- .../src/pages/user/activity.heatmap.vue | 4 +- .../src/pages/user/activity.notes.vue | 4 +- .../frontend/src/pages/user/activity.pv.vue | 4 +- .../frontend/src/pages/user/followers.vue | 4 +- .../frontend/src/pages/user/following.vue | 4 +- packages/frontend/src/pages/user/home.vue | 6 +-- .../frontend/src/pages/user/index.files.vue | 4 +- packages/frontend/src/pages/user/index.vue | 4 +- .../frontend/src/pages/welcome.entrance.a.vue | 6 +-- packages/frontend/src/pages/welcome.setup.vue | 3 +- .../frontend/src/pages/welcome.timeline.vue | 4 +- packages/frontend/src/pages/welcome.vue | 4 +- packages/frontend/src/pizzax.ts | 6 +-- packages/frontend/src/scripts/achievements.ts | 4 +- packages/frontend/src/scripts/aiscript/api.ts | 3 +- packages/frontend/src/scripts/clicker-game.ts | 6 +-- .../frontend/src/scripts/gen-search-query.ts | 2 +- .../src/scripts/get-drive-file-menu.ts | 9 +++-- .../frontend/src/scripts/get-note-menu.ts | 23 ++++++----- .../frontend/src/scripts/get-user-menu.ts | 3 +- .../frontend/src/scripts/install-plugin.ts | 3 +- packages/frontend/src/scripts/lookup-user.ts | 5 ++- packages/frontend/src/scripts/lookup.ts | 3 +- .../src/scripts/{api.ts => misskey-api.ts} | 4 +- packages/frontend/src/scripts/select-file.ts | 3 +- packages/frontend/src/scripts/sound.ts | 4 +- packages/frontend/src/theme-store.ts | 8 ++-- packages/frontend/src/ui/_common_/common.vue | 3 +- .../src/ui/_common_/statusbar-federation.vue | 4 +- .../src/ui/_common_/statusbar-user-list.vue | 4 +- .../frontend/src/ui/_common_/sw-inject.ts | 7 ++-- .../frontend/src/ui/deck/antenna-column.vue | 3 +- .../frontend/src/ui/deck/channel-column.vue | 5 ++- packages/frontend/src/ui/deck/deck-store.ts | 10 ++--- packages/frontend/src/ui/deck/list-column.vue | 3 +- .../src/ui/deck/role-timeline-column.vue | 3 +- packages/frontend/src/ui/visitor.vue | 3 +- .../frontend/src/widgets/WidgetActivity.vue | 4 +- .../src/widgets/WidgetBirthdayFollowings.vue | 4 +- .../frontend/src/widgets/WidgetFederation.vue | 6 +-- .../src/widgets/WidgetInstanceCloud.vue | 3 +- .../src/widgets/WidgetOnlineUsers.vue | 4 +- .../frontend/src/widgets/WidgetPhotos.vue | 4 +- .../frontend/src/widgets/WidgetSlideshow.vue | 3 +- .../frontend/src/widgets/WidgetTimeline.vue | 5 ++- .../frontend/src/widgets/WidgetTrends.vue | 4 +- .../frontend/src/widgets/WidgetUserList.vue | 7 ++-- .../src/widgets/server-metric/index.vue | 4 +- 191 files changed, 581 insertions(+), 468 deletions(-) rename packages/frontend/src/scripts/{api.ts => misskey-api.ts} (91%) diff --git a/packages/frontend/src/account.ts b/packages/frontend/src/account.ts index 25af29891..b01a80d13 100644 --- a/packages/frontend/src/account.ts +++ b/packages/frontend/src/account.ts @@ -11,7 +11,8 @@ import { miLocalStorage } from '@/local-storage.js'; import { MenuButton } from '@/types/menu.js'; import { del, get, set } from '@/scripts/idb-proxy.js'; import { apiUrl } from '@/config.js'; -import { waiting, api, popup, popupMenu, success, alert } from '@/os.js'; +import { waiting, popup, popupMenu, success, alert } from '@/os.js'; +import { misskeyApi } from '@/scripts/misskey-api.js'; import { unisonReload, reloadChannel } from '@/scripts/unison-reload.js'; // TODO: 他のタブと永続化されたstateを同期 @@ -251,7 +252,7 @@ export async function openAccountMenu(opts: { } const storedAccounts = await getAccounts().then(accounts => accounts.filter(x => x.id !== $i.id)); - const accountsPromise = api('users/show', { userIds: storedAccounts.map(x => x.id) }); + const accountsPromise = misskeyApi('users/show', { userIds: storedAccounts.map(x => x.id) }); function createItem(account: Misskey.entities.UserDetailed) { return { diff --git a/packages/frontend/src/cache.ts b/packages/frontend/src/cache.ts index 25d2b3c15..20950add8 100644 --- a/packages/frontend/src/cache.ts +++ b/packages/frontend/src/cache.ts @@ -5,9 +5,9 @@ import * as Misskey from 'misskey-js'; import { Cache } from '@/scripts/cache.js'; -import { api } from '@/os.js'; +import { misskeyApi } from '@/scripts/misskey-api.js'; -export const clipsCache = new Cache(1000 * 60 * 30, () => api('clips/list')); -export const rolesCache = new Cache(1000 * 60 * 30, () => api('admin/roles/list')); -export const userListsCache = new Cache(1000 * 60 * 30, () => api('users/lists/list')); -export const antennasCache = new Cache(1000 * 60 * 30, () => api('antennas/list')); +export const clipsCache = new Cache(1000 * 60 * 30, () => misskeyApi('clips/list')); +export const rolesCache = new Cache(1000 * 60 * 30, () => misskeyApi('admin/roles/list')); +export const userListsCache = new Cache(1000 * 60 * 30, () => misskeyApi('users/lists/list')); +export const antennasCache = new Cache(1000 * 60 * 30, () => misskeyApi('antennas/list')); diff --git a/packages/frontend/src/components/MkAccountMoved.vue b/packages/frontend/src/components/MkAccountMoved.vue index 155d9fe3a..a5b43d3c6 100644 --- a/packages/frontend/src/components/MkAccountMoved.vue +++ b/packages/frontend/src/components/MkAccountMoved.vue @@ -17,7 +17,7 @@ import * as Misskey from 'misskey-js'; import MkMention from './MkMention.vue'; import { i18n } from '@/i18n.js'; import { host as localHost } from '@/config.js'; -import { api } from '@/os.js'; +import { misskeyApi } from '@/scripts/misskey-api.js'; const user = ref(); @@ -25,7 +25,7 @@ const props = defineProps<{ movedTo: string; // user id }>(); -api('users/show', { userId: props.movedTo }).then(u => user.value = u); +misskeyApi('users/show', { userId: props.movedTo }).then(u => user.value = u);