diff --git a/src/client/components/drive.folder.vue b/src/client/components/drive.folder.vue index 5664fb8c624627e088fe8b4cb431bbf2cce781b0..ab678217b6c55517dc00d8c4de2530e541fd7a91 100644 --- a/src/client/components/drive.folder.vue +++ b/src/client/components/drive.folder.vue @@ -248,8 +248,8 @@ export default defineComponent({ os.contextMenu([{ text: this.$t('openInWindow'), icon: faWindowRestore, - action: async () => { - os.popup(await import('./drive-window.vue'), { + action: () => { + os.popup(import('./drive-window.vue'), { initialFolder: this.folder }, { }, 'closed'); diff --git a/src/client/components/link.vue b/src/client/components/link.vue index bac49a62ef4d45ae67f6fb58bf300cec43817eb0..f51773dc4b134faf6e8d4ff37aae7e6dcb96d576 100644 --- a/src/client/components/link.vue +++ b/src/client/components/link.vue @@ -46,7 +46,7 @@ export default defineComponent({ if (!document.body.contains(this.$el)) return; if (this.close) return; - const { dispose } = os.popup(await import('@/components/url-preview-popup.vue'), { + const { dispose } = await os.popup(import('@/components/url-preview-popup.vue'), { url: this.url, source: this.$el }); diff --git a/src/client/components/note.vue b/src/client/components/note.vue index 609098f82cabdedac949b4501073e2f547041f1f..377496b402ce2f6d9e2a7c33bacfbf549901f9a8 100644 --- a/src/client/components/note.vue +++ b/src/client/components/note.vue @@ -498,7 +498,7 @@ export default defineComponent({ react(viaKeyboard = false) { pleaseLogin(); this.blur(); - os.popup(defineAsyncComponent(() => import('@/components/reaction-picker.vue')), { + os.popup(import('@/components/reaction-picker.vue'), { showFocus: viaKeyboard, src: this.$refs.reactButton, }, { @@ -644,7 +644,7 @@ export default defineComponent({ text: this.$t('reportAbuse'), action: () => { const u = `${url}/notes/${this.appearNote.id}`; - os.popup(defineAsyncComponent(() => import('@/components/abuse-report-window.vue')), { + os.popup(import('@/components/abuse-report-window.vue'), { user: this.appearNote.user, initialComment: `Note: ${u}\n-----\n` }, {}, 'closed'); diff --git a/src/client/components/post-form.vue b/src/client/components/post-form.vue index 2eb807af5adf90b56f0a194c7a5ac8857429c512..020b925fb9cd52b7e9e0a1f7527489cec23f91cc 100644 --- a/src/client/components/post-form.vue +++ b/src/client/components/post-form.vue @@ -378,13 +378,13 @@ export default defineComponent({ this.saveDraft(); }, - async setVisibility() { + setVisibility() { if (this.channel) { // TODO: information dialog return; } - os.popup(await import('./visibility-picker.vue'), { + os.popup(import('./visibility-picker.vue'), { currentVisibility: this.visibility, currentLocalOnly: this.localOnly, src: this.$refs.visibilityButton diff --git a/src/client/components/sidebar.vue b/src/client/components/sidebar.vue index 47bc8830ecd7ee565b879b60e97950798d73b3ca..ae9fff816f4596be76ad0e97e91a75fd145845d9 100644 --- a/src/client/components/sidebar.vue +++ b/src/client/components/sidebar.vue @@ -257,8 +257,8 @@ export default defineComponent({ }], ev.currentTarget || ev.target); }, - async addAcount() { - os.popup(await import('./signin-dialog.vue'), {}, { + addAcount() { + os.popup(import('./signin-dialog.vue'), {}, { done: res => { this.$store.dispatch('addAcount', res); os.success(); @@ -266,8 +266,8 @@ export default defineComponent({ }, 'closed'); }, - async createAccount() { - os.popup(await import('./signup-dialog.vue'), {}, { + createAccount() { + os.popup(import('./signup-dialog.vue'), {}, { done: res => { this.$store.dispatch('addAcount', res); this.switchAccountWithToken(res.i); @@ -275,7 +275,7 @@ export default defineComponent({ }, 'closed'); }, - async switchAccount(account: any) { + switchAccount(account: any) { const token = this.$store.state.device.accounts.find((x: any) => x.id === account.id).token; this.switchAccountWithToken(token); }, diff --git a/src/client/components/taskmanager.vue b/src/client/components/taskmanager.vue index 91b52ecc3eada6d9302b3c8ce08e9a71b74f51ae..ab8d4a80dd019d602f22472b9cf76d67bf71a79e 100644 --- a/src/client/components/taskmanager.vue +++ b/src/client/components/taskmanager.vue @@ -119,8 +119,8 @@ export default defineComponent({ os.popups.value = os.popups.value.filter(x => x !== p); }; - const showReq = async req => { - os.popup(await import('./taskmanager.api-window.vue'), { + const showReq = req => { + os.popup(import('./taskmanager.api-window.vue'), { req: req }, { }, 'closed'); diff --git a/src/client/components/url.vue b/src/client/components/url.vue index ceb0381f87fea0d1f8b6e51d4d0e53d46bcfd735..c7e93094f5fb9c09c53d5eae7d6d4b3b49504918 100644 --- a/src/client/components/url.vue +++ b/src/client/components/url.vue @@ -71,7 +71,7 @@ export default defineComponent({ if (!document.body.contains(this.$el)) return; if (this.close) return; - const { dispose } = os.popup(await import('@/components/url-preview-popup.vue'), { + const { dispose } = await os.popup(import('@/components/url-preview-popup.vue'), { url: this.url, source: this.$el }); diff --git a/src/client/directives/tooltip.ts b/src/client/directives/tooltip.ts index f232ea47c760dfdb40323731791d3f3fd91fc1aa..faeeef79a7cc33c24e5d7365ba6f03720c0370d0 100644 --- a/src/client/directives/tooltip.ts +++ b/src/client/directives/tooltip.ts @@ -23,13 +23,13 @@ export default { } }; - const show = async e => { + const show = e => { if (!document.body.contains(el)) return; if (self._close) return; if (self.text == null) return; const showing = ref(true); - popup(await import('@/components/ui/tooltip.vue'), { + popup(import('@/components/ui/tooltip.vue'), { showing, text: self.text, source: el diff --git a/src/client/directives/user-preview.ts b/src/client/directives/user-preview.ts index 0fe05aca40561b9df2b6d625845b51362e62b749..68d9e2816cad717910b0a49cfee39477befcd147 100644 --- a/src/client/directives/user-preview.ts +++ b/src/client/directives/user-preview.ts @@ -18,13 +18,13 @@ export class UserPreview { } @autobind - private async show() { + private show() { if (!document.body.contains(this.el)) return; if (this.promise) return; const showing = ref(true); - popup(await import('@/components/user-preview.vue'), { + popup(import('@/components/user-preview.vue'), { showing, q: this.user, source: this.el diff --git a/src/client/os.ts b/src/client/os.ts index 39032b61f13f1592288c8aca5a7d5f9247f9bfc3..898b876589b02640c2f42d23631618bf7c6fbc3f 100644 --- a/src/client/os.ts +++ b/src/client/os.ts @@ -147,7 +147,9 @@ export const popups = ref([]) as Ref<{ props: Record<string, any>; }[]>; -export function popup(component: Component | typeof import('*.vue'), props: Record<string, any>, events = {}, disposeEvent?: string) { +export async function popup(component: Component | typeof import('*.vue') | Promise<Component | typeof import('*.vue')>, props: Record<string, any>, events = {}, disposeEvent?: string) { + if (component.then) component = await component; + if (isModule(component)) component = component.default; markRaw(component); @@ -179,7 +181,7 @@ export function popup(component: Component | typeof import('*.vue'), props: Reco export function pageWindow(path: string) { const { component, props } = resolve(path); - popup(defineAsyncComponent(() => import('@/components/page-window.vue')), { + popup(import('@/components/page-window.vue'), { initialPath: path, initialComponent: markRaw(component), initialProps: props, @@ -188,7 +190,7 @@ export function pageWindow(path: string) { export function dialog(props: Record<string, any>) { return new Promise((resolve, reject) => { - popup(defineAsyncComponent(() => import('@/components/dialog.vue')), props, { + popup(import('@/components/dialog.vue'), props, { done: result => { resolve(result ? result : { canceled: true }); }, @@ -202,7 +204,7 @@ export function success() { setTimeout(() => { showing.value = false; }, 1000); - popup(defineAsyncComponent(() => import('@/components/waiting-dialog.vue')), { + popup(import('@/components/waiting-dialog.vue'), { success: true, showing: showing }, { @@ -214,7 +216,7 @@ export function success() { export function waiting() { return new Promise((resolve, reject) => { const showing = ref(true); - popup(defineAsyncComponent(() => import('@/components/waiting-dialog.vue')), { + popup(import('@/components/waiting-dialog.vue'), { success: false, showing: showing }, { @@ -225,7 +227,7 @@ export function waiting() { export function form(title, form) { return new Promise((resolve, reject) => { - popup(defineAsyncComponent(() => import('@/components/form-dialog.vue')), { title, form }, { + popup(import('@/components/form-dialog.vue'), { title, form }, { done: result => { resolve(result); }, @@ -235,7 +237,7 @@ export function form(title, form) { export async function selectUser() { return new Promise((resolve, reject) => { - popup(defineAsyncComponent(() => import('@/components/user-select-dialog.vue')), {}, { + popup(import('@/components/user-select-dialog.vue'), {}, { ok: user => { resolve(user); }, @@ -245,7 +247,7 @@ export async function selectUser() { export async function selectDriveFile(multiple: boolean) { return new Promise((resolve, reject) => { - popup(defineAsyncComponent(() => import('@/components/drive-select-dialog.vue')), { + popup(import('@/components/drive-select-dialog.vue'), { type: 'file', multiple }, { @@ -260,7 +262,7 @@ export async function selectDriveFile(multiple: boolean) { export async function selectDriveFolder(multiple: boolean) { return new Promise((resolve, reject) => { - popup(defineAsyncComponent(() => import('@/components/drive-select-dialog.vue')), { + popup(import('@/components/drive-select-dialog.vue'), { type: 'folder', multiple }, { @@ -275,7 +277,7 @@ export async function selectDriveFolder(multiple: boolean) { export async function pickEmoji(src?: HTMLElement) { return new Promise((resolve, reject) => { - popup(defineAsyncComponent(() => import('@/components/emoji-picker.vue')), { + popup(import('@/components/emoji-picker.vue'), { src }, { done: emoji => { @@ -287,7 +289,8 @@ export async function pickEmoji(src?: HTMLElement) { export function modalMenu(items: any[], src?: HTMLElement, options?: { align?: string; viaKeyboard?: boolean }) { return new Promise((resolve, reject) => { - const { dispose } = popup(defineAsyncComponent(() => import('@/components/ui/modal-menu.vue')), { + let dispose; + popup(import('@/components/ui/modal-menu.vue'), { items, src, align: options?.align, @@ -297,6 +300,8 @@ export function modalMenu(items: any[], src?: HTMLElement, options?: { align?: s resolve(); dispose(); }, + }).then(_dispose => { + dispose = _dispose; }); }); } @@ -304,7 +309,8 @@ export function modalMenu(items: any[], src?: HTMLElement, options?: { align?: s export function contextMenu(items: any[], ev: MouseEvent) { ev.preventDefault(); return new Promise((resolve, reject) => { - const { dispose } = popup(defineAsyncComponent(() => import('@/components/ui/context-menu.vue')), { + let dispose; + popup(import('@/components/ui/context-menu.vue'), { items, ev, }, { @@ -312,6 +318,8 @@ export function contextMenu(items: any[], ev: MouseEvent) { resolve(); dispose(); }, + }).then(_dispose => { + dispose = _dispose; }); }); } @@ -323,11 +331,14 @@ export function post(props: Record<string, any>) { // VueãŒæ¸¡ã•ã‚ŒãŸã‚³ãƒ³ãƒãƒ¼ãƒãƒ³ãƒˆã«å†…部的ã«__propsã¨ã„ã†ãƒ—ãƒãƒ‘ティを生やã™å½±éŸ¿ã§ã€ // 複数ã®post formã‚’é–‹ã„ãŸã¨ãã«å ´åˆã«ã‚ˆã£ã¦ã¯ã‚¨ãƒ©ãƒ¼ã«ãªã‚‹ // ã‚‚ã¡ã‚ん複数ã®post formã‚’é–‹ã‘ã‚‹ã“ã¨è‡ªä½“Misskeyサイドã®ãƒã‚°ãªã®ã ㌠- const { dispose } = popup(MkPostFormDialog, props, { + let dispose; + popup(MkPostFormDialog, props, { closed: () => { resolve(); dispose(); }, + }).then(_dispose => { + dispose = _dispose; }); }); } diff --git a/src/client/pages/instance/emojis.vue b/src/client/pages/instance/emojis.vue index 9001a5c5ebfce2a0f06a5f338e92eeaee0b063ec..f33383776cd113839be0b76c3f1e7c7379786e09 100644 --- a/src/client/pages/instance/emojis.vue +++ b/src/client/pages/instance/emojis.vue @@ -113,8 +113,8 @@ export default defineComponent({ os.promiseDialog(promise); }, - async edit(emoji) { - os.popup(await import('./emoji-edit-dialog.vue'), { + edit(emoji) { + os.popup(import('./emoji-edit-dialog.vue'), { emoji: emoji }, { done: result => { diff --git a/src/client/pages/instance/file-dialog.vue b/src/client/pages/instance/file-dialog.vue index c03a691bfd2e0529432f5615d689e3fdfbf92d9d..79244349e35ddcfc5a5e36425d28ede5394da359 100644 --- a/src/client/pages/instance/file-dialog.vue +++ b/src/client/pages/instance/file-dialog.vue @@ -84,8 +84,8 @@ export default defineComponent({ Progress.done(); }, - async showUser() { - os.popup(await import('./user-dialog.vue'), { + showUser() { + os.popup(import('./user-dialog.vue'), { userId: this.file.userId }, {}, 'closed'); }, diff --git a/src/client/pages/instance/files.vue b/src/client/pages/instance/files.vue index 29efe08a3909f694c177369a3110ae0a64deffb7..3c1d90f24f42f66205ea4be5af62a5dfa5b6755d 100644 --- a/src/client/pages/instance/files.vue +++ b/src/client/pages/instance/files.vue @@ -131,8 +131,8 @@ export default defineComponent({ }); }, - async show(file, ev) { - os.popup(await import('./file-dialog.vue'), { + show(file, ev) { + os.popup(import('./file-dialog.vue'), { fileId: file.id }, {}, 'closed'); }, diff --git a/src/client/pages/instance/users.vue b/src/client/pages/instance/users.vue index b891ed841247d67f40d88080d1fdd7980eafd333..43ea79656d143d5735413de9bd2c028cd770f22a 100644 --- a/src/client/pages/instance/users.vue +++ b/src/client/pages/instance/users.vue @@ -206,8 +206,8 @@ export default defineComponent({ }); }, - async show(user) { - os.popup(await import('./user-dialog.vue'), { + show(user) { + os.popup(import('./user-dialog.vue'), { userId: user.id }, {}, 'closed'); }, diff --git a/src/client/pages/settings/api.vue b/src/client/pages/settings/api.vue index 6a311cdc8b0f3a4bfb853f1fd0e0344f6fd7b703..80a558ff854ca0dad8884f81c5cb1488728e1593 100644 --- a/src/client/pages/settings/api.vue +++ b/src/client/pages/settings/api.vue @@ -42,8 +42,8 @@ export default defineComponent({ }, methods: { - async generateToken() { - os.popup(await import('@/components/token-generate-window.vue'), {}, { + generateToken() { + os.popup(import('@/components/token-generate-window.vue'), {}, { done: async result => { const { name, permissions } = result; const { token } = await os.api('miauth/gen-token', { diff --git a/src/client/pages/settings/notifications.vue b/src/client/pages/settings/notifications.vue index 98dc85ea525616c0a520afb4692eb0c1d2163ffd..6d73e79a31302be32a4d5500e12467c1eedb61a1 100644 --- a/src/client/pages/settings/notifications.vue +++ b/src/client/pages/settings/notifications.vue @@ -72,9 +72,9 @@ export default defineComponent({ os.api('notifications/mark-all-as-read'); }, - async configure() { + configure() { const includingTypes = notificationTypes.filter(x => !this.$store.state.i.mutingNotificationTypes.includes(x)); - os.popup(await import('@/components/notification-setting-window.vue'), { + os.popup(import('@/components/notification-setting-window.vue'), { includingTypes, showGlobalToggle: false, }, { diff --git a/src/client/pages/settings/other.vue b/src/client/pages/settings/other.vue index dbeb9ad7190c5b1a8b41f4d5578b2e4fb7ea09b7..0faf4e4c85db122aca554057c56ff5406d66a965 100644 --- a/src/client/pages/settings/other.vue +++ b/src/client/pages/settings/other.vue @@ -69,7 +69,7 @@ export default defineComponent({ }, taskmanager() { - os.popup(defineAsyncComponent(() => import('@/components/taskmanager.vue')), { + os.popup(import('@/components/taskmanager.vue'), { }, {}, 'closed'); } } diff --git a/src/client/pages/settings/plugins.vue b/src/client/pages/settings/plugins.vue index 246624ddd475c37c7ecc8d7452600e4d0ddc7869..6cedf025480a8123855ae25cbcc354edd0975d1a 100644 --- a/src/client/pages/settings/plugins.vue +++ b/src/client/pages/settings/plugins.vue @@ -117,8 +117,8 @@ export default defineComponent({ return; } - const token = permissions == null || permissions.length === 0 ? null : await new Promise(async (res, rej) => { - os.popup(await import('@/components/token-generate-window.vue'), { + const token = permissions == null || permissions.length === 0 ? null : await new Promise((res, rej) => { + os.popup(import('@/components/token-generate-window.vue'), { title: this.$t('tokenRequested'), information: this.$t('pluginTokenRequestedDescription'), initialName: name, diff --git a/src/client/pages/settings/reaction.vue b/src/client/pages/settings/reaction.vue index 683cf6dfbe6774ceb89f1d231f816252e4a53ba6..8d76d65ed1e5f743515a0b19a939a89df6d3a5d4 100644 --- a/src/client/pages/settings/reaction.vue +++ b/src/client/pages/settings/reaction.vue @@ -73,8 +73,8 @@ export default defineComponent({ this.changed = false; }, - async preview(ev) { - os.popup(await import('@/components/reaction-picker.vue'), { + preview(ev) { + os.popup(import('@/components/reaction-picker.vue'), { reactions: this.splited, showFocus: false, src: ev.currentTarget || ev.target, @@ -85,7 +85,7 @@ export default defineComponent({ this.reactions = defaultSettings.reactions.join(''); }, - async chooseEmoji(ev) { + chooseEmoji(ev) { os.pickEmoji(ev.currentTarget || ev.target).then(emoji => { this.reactions += emoji; }); diff --git a/src/client/scripts/get-user-menu.ts b/src/client/scripts/get-user-menu.ts index 693e573b07e5c1f53ec14aad0df555a8ff744f52..c3de7313cc13413d5a0ec36e5c12f88289132046 100644 --- a/src/client/scripts/get-user-menu.ts +++ b/src/client/scripts/get-user-menu.ts @@ -101,8 +101,8 @@ export function getUserMenu(user) { }); } - async function reportAbuse() { - os.popup(await import('@/components/abuse-report-window.vue'), { + function reportAbuse() { + os.popup(import('@/components/abuse-report-window.vue'), { user: user, }, {}, 'closed'); } diff --git a/src/client/ui/deck.vue b/src/client/ui/deck.vue index ce54a6672d2f1d58468d362481bc24990070bff6..ff1daa58a00c62c6f90fd0e23346f893b71a2d2c 100644 --- a/src/client/ui/deck.vue +++ b/src/client/ui/deck.vue @@ -143,7 +143,7 @@ export default defineComponent({ os.post(); }, - async onNotification(notification) { + onNotification(notification) { if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) { return; } @@ -153,7 +153,7 @@ export default defineComponent({ id: notification.id }); - os.popup(await import('@/components/toast.vue'), { + os.popup(import('@/components/toast.vue'), { notification }, {}, 'closed'); } diff --git a/src/client/ui/deck/notifications-column.vue b/src/client/ui/deck/notifications-column.vue index 6284cdcd0b9adb0662ce8fb450ed155b026a4365..a6281a766ad4b65a981b126ddd4d5a61ef5ba028 100644 --- a/src/client/ui/deck/notifications-column.vue +++ b/src/client/ui/deck/notifications-column.vue @@ -42,8 +42,8 @@ export default defineComponent({ this.menu = [{ icon: faCog, text: this.$t('notificationSetting'), - action: async () => { - os.popup(await import('@/components/notification-setting-window.vue'), { + action: () => { + os.popup(import('@/components/notification-setting-window.vue'), { includingTypes: this.column.includingTypes, }, { done: async (res) => { diff --git a/src/client/ui/default.vue b/src/client/ui/default.vue index 626e5242c541293158a0ddb7e4110602788d5738..2c9d8426760480584f319b7453e49060d89c0c21 100644 --- a/src/client/ui/default.vue +++ b/src/client/ui/default.vue @@ -235,7 +235,7 @@ export default defineComponent({ }], e); }, - async onNotification(notification) { + onNotification(notification) { if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) { return; } @@ -244,7 +244,7 @@ export default defineComponent({ id: notification.id }); - os.popup(await import('@/components/toast.vue'), { + os.popup(import('@/components/toast.vue'), { notification }, {}, 'closed'); } diff --git a/src/client/ui/zen.vue b/src/client/ui/zen.vue index dbf9430e789e11acc7106bd3bb270335a551b618..e3aa077bd7dc157d3cf4cd785a18d34fbc90fd3b 100644 --- a/src/client/ui/zen.vue +++ b/src/client/ui/zen.vue @@ -95,7 +95,7 @@ export default defineComponent({ if (window._scroll) window._scroll(); }, - async onNotification(notification) { + onNotification(notification) { if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) { return; } @@ -104,7 +104,7 @@ export default defineComponent({ id: notification.id }); - os.popup(await import('@/components/toast.vue'), { + os.popup(import('@/components/toast.vue'), { notification }, {}, 'closed'); } diff --git a/src/client/widgets/notifications.vue b/src/client/widgets/notifications.vue index 490c4d758f85267406c9ba060470e90c9a5afce9..7937ffb0a554a09e54179feacc494d31a3ba2309 100644 --- a/src/client/widgets/notifications.vue +++ b/src/client/widgets/notifications.vue @@ -51,8 +51,8 @@ export default defineComponent({ }, methods: { - async configure() { - os.popup(await import('@/components/notification-setting-window.vue'), { + configure() { + os.popup(import('@/components/notification-setting-window.vue'), { includingTypes: this.props.includingTypes, }, { done: async (res) => {