enhance(frontend): 非同期的なコンポーネントの読み込み時のハンドリングを強化

This commit is contained in:
syuilo 2025-06-01 10:44:45 +09:00
parent 63db879bcc
commit f4167ae7f1
33 changed files with 120 additions and 72 deletions

View File

@ -4,6 +4,7 @@
- -
### Client ### Client
- Enhance: 非同期的なコンポーネントの読み込み時のハンドリングを強化
- Fix: リアクションの一部の絵文字が重複して表示されることがある問題を修正 - Fix: リアクションの一部の絵文字が重複して表示されることがある問題を修正
### Server ### Server

View File

@ -282,8 +282,8 @@ function onContextmenu(ev: MouseEvent) {
menu = [{ menu = [{
text: i18n.ts.openInWindow, text: i18n.ts.openInWindow,
icon: 'ti ti-app-window', icon: 'ti ti-app-window',
action: () => { action: async () => {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkDriveWindow.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkDriveWindow.vue').then(x => x.default), {
initialFolder: props.folder, initialFolder: props.folder,
}, { }, {
closed: () => dispose(), closed: () => dispose(),

View File

@ -126,7 +126,7 @@ async function rename(file) {
async function describe(file: Misskey.entities.DriveFile) { async function describe(file: Misskey.entities.DriveFile) {
if (mock) return; if (mock) return;
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkFileCaptionEditWindow.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkFileCaptionEditWindow.vue').then(x => x.default), {
default: file.comment !== null ? file.comment : '', default: file.comment !== null ? file.comment : '',
file: file, file: file,
}, { }, {
@ -168,9 +168,11 @@ function showFileMenu(file: Misskey.entities.DriveFile, ev: MouseEvent | Keyboar
menuItems.push({ menuItems.push({
text: i18n.ts.preview, text: i18n.ts.preview,
icon: 'ti ti-photo-search', icon: 'ti ti-photo-search',
action: () => { action: async () => {
os.popup(defineAsyncComponent(() => import('@/components/MkImgPreviewDialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkImgPreviewDialog.vue').then(x => x.default), {
file: file, file: file,
}, {
closed: () => dispose(),
}); });
}, },
}); });

View File

@ -174,8 +174,8 @@ function setupComplete() {
function launchTutorial() { function launchTutorial() {
setupComplete(); setupComplete();
nextTick(() => { nextTick(async () => {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkTutorialDialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkTutorialDialog.vue').then(x => x.default), {
initialPage: 1, initialPage: 1,
}, { }, {
closed: () => dispose(), closed: () => dispose(),

View File

@ -185,7 +185,7 @@ async function edit(name: string) {
const emoji = await misskeyApi('emoji', { const emoji = await misskeyApi('emoji', {
name: name, name: name,
}); });
const { dispose } = os.popup(defineAsyncComponent(() => import('@/pages/emoji-edit-dialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/pages/emoji-edit-dialog.vue').then(x => x.default), {
emoji: emoji, emoji: emoji,
}, { }, {
closed: () => dispose(), closed: () => dispose(),

View File

@ -206,6 +206,52 @@ export function popup<T extends Component>(
}; };
} }
export async function popupAsyncWithDialog<T extends Component>(
componentFetching: Promise<T>,
props: ComponentProps<T>,
events: Partial<ComponentEmit<T>> = {},
): Promise<{ dispose: () => void }> {
const closeWaiting = waiting();
let component: T;
try {
component = await componentFetching;
} catch (err) {
closeWaiting();
alert({
type: 'error',
title: i18n.ts.somethingHappened,
text: 'CODE: ASYNC_COMP_LOAD_FAIL',
});
throw err;
}
closeWaiting();
markRaw(component);
const id = ++popupIdCount;
const dispose = () => {
// このsetTimeoutが無いと挙動がおかしくなる(autocompleteが閉じなくなる)。Vueのバグ
window.setTimeout(() => {
popups.value = popups.value.filter(p => p.id !== id);
}, 0);
};
const state = {
component,
props,
events,
id,
};
popups.value.push(state);
return {
dispose,
};
}
export function pageWindow(path: string) { export function pageWindow(path: string) {
const { dispose } = popup(MkPageWindow, { const { dispose } = popup(MkPageWindow, {
initialPath: path, initialPath: path,
@ -787,9 +833,9 @@ export function launchUploader(
multiple?: boolean; multiple?: boolean;
}, },
): Promise<Misskey.entities.DriveFile[]> { ): Promise<Misskey.entities.DriveFile[]> {
return new Promise((res, rej) => { return new Promise(async (res, rej) => {
if (files.length === 0) return rej(); if (files.length === 0) return rej();
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkUploaderDialog.vue')), { const { dispose } = await popupAsyncWithDialog(import('@/components/MkUploaderDialog.vue').then(x => x.default), {
files: markRaw(files), files: markRaw(files),
folderId: options?.folderId, folderId: options?.folderId,
multiple: options?.multiple, multiple: options?.multiple,

View File

@ -477,16 +477,16 @@ function toggleRoleItem(role) {
} }
} }
function createAnnouncement() { async function createAnnouncement() {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkUserAnnouncementEditDialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkUserAnnouncementEditDialog.vue').then(x => x.default), {
user: user.value, user: user.value,
}, { }, {
closed: () => dispose(), closed: () => dispose(),
}); });
} }
function editAnnouncement(announcement) { async function editAnnouncement(announcement) {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkUserAnnouncementEditDialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkUserAnnouncementEditDialog.vue').then(x => x.default), {
user: user.value, user: user.value,
announcement, announcement,
}, { }, {

View File

@ -525,10 +525,10 @@ const headerPageMetadata = computed(() => ({
const headerActions = computed(() => [{ const headerActions = computed(() => [{
icon: 'ti ti-search', icon: 'ti ti-search',
text: i18n.ts.search, text: i18n.ts.search,
handler: () => { handler: async () => {
if (searchWindowOpening) return; if (searchWindowOpening) return;
searchWindowOpening = true; searchWindowOpening = true;
const { dispose } = os.popup(defineAsyncComponent(() => import('./custom-emojis-manager.local.list.search.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('./custom-emojis-manager.local.list.search.vue').then(x => x.default), {
query: searchQuery.value, query: searchQuery.value,
}, { }, {
queryUpdated: (query: EmojiSearchQuery) => { queryUpdated: (query: EmojiSearchQuery) => {
@ -584,8 +584,8 @@ const headerActions = computed(() => [{
}, { }, {
icon: 'ti ti-notes', icon: 'ti ti-notes',
text: i18n.ts._customEmojisManager._gridCommon.registrationLogs, text: i18n.ts._customEmojisManager._gridCommon.registrationLogs,
handler: () => { handler: async () => {
const { dispose } = os.popup(defineAsyncComponent(() => import('./custom-emojis-manager.local.list.logs.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('./custom-emojis-manager.local.list.logs.vue').then(x => x.default), {
logs: requestLogs.value, logs: requestLogs.value,
}, { }, {
closed: () => { closed: () => {

View File

@ -46,7 +46,7 @@ function load() {
load(); load();
async function add(ev: MouseEvent) { async function add(ev: MouseEvent) {
const { dispose } = os.popup(defineAsyncComponent(() => import('./avatar-decoration-edit-dialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('./avatar-decoration-edit-dialog.vue').then(x => x.default), {
}, { }, {
done: result => { done: result => {
if (result.created) { if (result.created) {
@ -57,8 +57,8 @@ async function add(ev: MouseEvent) {
}); });
} }
function edit(avatarDecoration) { async function edit(avatarDecoration) {
const { dispose } = os.popup(defineAsyncComponent(() => import('./avatar-decoration-edit-dialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('./avatar-decoration-edit-dialog.vue').then(x => x.default), {
avatarDecoration: avatarDecoration, avatarDecoration: avatarDecoration,
}, { }, {
done: result => { done: result => {

View File

@ -181,9 +181,9 @@ function showMenu(ev: MouseEvent, contextmenu = false) {
menu.push({ menu.push({
text: i18n.ts.reportAbuse, text: i18n.ts.reportAbuse,
icon: 'ti ti-exclamation-circle', icon: 'ti ti-exclamation-circle',
action: () => { action: async () => {
const localUrl = `${url}/chat/messages/${props.message.id}`; const localUrl = `${url}/chat/messages/${props.message.id}`;
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkAbuseReportWindow.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkAbuseReportWindow.vue').then(x => x.default), {
user: props.message.fromUser!, user: props.message.fromUser!,
initialComment: `${localUrl}\n-----\n`, initialComment: `${localUrl}\n-----\n`,
}, { }, {

View File

@ -128,7 +128,7 @@ const toggleSelect = (emoji) => {
}; };
const add = async (ev: MouseEvent) => { const add = async (ev: MouseEvent) => {
const { dispose } = os.popup(defineAsyncComponent(() => import('./emoji-edit-dialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('./emoji-edit-dialog.vue').then(x => x.default), {
}, { }, {
done: result => { done: result => {
if (result.created) { if (result.created) {
@ -139,8 +139,8 @@ const add = async (ev: MouseEvent) => {
}); });
}; };
const edit = (emoji) => { const edit = async (emoji) => {
const { dispose } = os.popup(defineAsyncComponent(() => import('./emoji-edit-dialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('./emoji-edit-dialog.vue').then(x => x.default), {
emoji: emoji, emoji: emoji,
}, { }, {
done: result => { done: result => {

View File

@ -174,10 +174,10 @@ function rename() {
}); });
} }
function describe() { async function describe() {
if (!file.value) return; if (!file.value) return;
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkFileCaptionEditWindow.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkFileCaptionEditWindow.vue').then(x => x.default), {
default: file.value.comment ?? '', default: file.value.comment ?? '',
file: file.value, file: file.value,
}, { }, {

View File

@ -67,7 +67,7 @@ function menu(ev) {
} }
const edit = async (emoji) => { const edit = async (emoji) => {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/pages/emoji-edit-dialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/pages/emoji-edit-dialog.vue').then(x => x.default), {
emoji: emoji, emoji: emoji,
}, { }, {
closed: () => dispose(), closed: () => dispose(),

View File

@ -238,12 +238,12 @@ async function run() {
} }
} }
function reportAbuse() { async function reportAbuse() {
if (!flash.value) return; if (!flash.value) return;
const pageUrl = `${url}/play/${flash.value.id}`; const pageUrl = `${url}/play/${flash.value.id}`;
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkAbuseReportWindow.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkAbuseReportWindow.vue').then(x => x.default), {
user: flash.value.user, user: flash.value.user,
initialComment: `Play: ${pageUrl}\n-----\n`, initialComment: `Play: ${pageUrl}\n-----\n`,
}, { }, {

View File

@ -153,12 +153,12 @@ function edit() {
router.push(`/gallery/${post.value.id}/edit`); router.push(`/gallery/${post.value.id}/edit`);
} }
function reportAbuse() { async function reportAbuse() {
if (!post.value) return; if (!post.value) return;
const pageUrl = `${url}/gallery/${post.value.id}`; const pageUrl = `${url}/gallery/${post.value.id}`;
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkAbuseReportWindow.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkAbuseReportWindow.vue').then(x => x.default), {
user: post.value.user, user: post.value.user,
initialComment: `Post: ${pageUrl}\n-----\n`, initialComment: `Post: ${pageUrl}\n-----\n`,
}, { }, {

View File

@ -245,12 +245,12 @@ function pin(pin) {
}); });
} }
function reportAbuse() { async function reportAbuse() {
if (!page.value) return; if (!page.value) return;
const pageUrl = `${url}/@${props.username}/pages/${props.pageName}`; const pageUrl = `${url}/@${props.username}/pages/${props.pageName}`;
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkAbuseReportWindow.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkAbuseReportWindow.vue').then(x => x.default), {
user: page.value.user, user: page.value.user,
initialComment: `Page: ${pageUrl}\n-----\n`, initialComment: `Page: ${pageUrl}\n-----\n`,
}, { }, {

View File

@ -41,9 +41,9 @@ async function save() {
mainRouter.push('/'); mainRouter.push('/');
} }
onMounted(() => { onMounted(async () => {
if (props.token == null) { if (props.token == null) {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkForgotPassword.vue')), {}, { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkForgotPassword.vue').then(x => x.default), {}, {
closed: () => dispose(), closed: () => dispose(),
}); });
mainRouter.push('/'); mainRouter.push('/');

View File

@ -117,7 +117,7 @@ async function registerTOTP(): Promise<void> {
token: auth.result.token, token: auth.result.token,
}); });
const { dispose } = os.popup(defineAsyncComponent(() => import('./2fa.qrdialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('./2fa.qrdialog.vue').then(x => x.default), {
twoFactorData, twoFactorData,
}, { }, {
closed: () => dispose(), closed: () => dispose(),

View File

@ -68,8 +68,8 @@ misskeyApi('get-avatar-decorations').then(_avatarDecorations => {
loading.value = false; loading.value = false;
}); });
function openDecoration(avatarDecoration, index?: number) { async function openDecoration(avatarDecoration, index?: number) {
const { dispose } = os.popup(defineAsyncComponent(() => import('./avatar-decoration.dialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('./avatar-decoration.dialog.vue').then(x => x.default), {
decoration: avatarDecoration, decoration: avatarDecoration,
usingIndex: index, usingIndex: index,
}, { }, {

View File

@ -81,8 +81,8 @@ const pagination = {
noPaging: true, noPaging: true,
}; };
function generateToken() { async function generateToken() {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkTokenGenerateWindow.vue')), {}, { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkTokenGenerateWindow.vue').then(x => x.default), {}, {
done: async result => { done: async result => {
const { name, permissions } = result; const { name, permissions } = result;
const { token } = await misskeyApi('miauth/gen-token', { const { token } = await misskeyApi('miauth/gen-token', {

View File

@ -95,8 +95,8 @@ export async function authorizePlugin(plugin: Plugin) {
if (plugin.permissions == null || plugin.permissions.length === 0) return; if (plugin.permissions == null || plugin.permissions.length === 0) return;
if (Object.hasOwn(store.s.pluginTokens, plugin.installId)) return; if (Object.hasOwn(store.s.pluginTokens, plugin.installId)) return;
const token = await new Promise<string>((res, rej) => { const token = await new Promise<string>(async (res, rej) => {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkTokenGenerateWindow.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkTokenGenerateWindow.vue').then(x => x.default), {
title: i18n.ts.tokenRequested, title: i18n.ts.tokenRequested,
information: i18n.ts.pluginTokenRequestedDescription, information: i18n.ts.pluginTokenRequestedDescription,
initialName: plugin.name, initialName: plugin.name,

View File

@ -4,10 +4,10 @@
*/ */
import { defineAsyncComponent } from 'vue'; import { defineAsyncComponent } from 'vue';
import { host } from '@@/js/config.js';
import type { MenuItem } from '@/types/menu.js'; import type { MenuItem } from '@/types/menu.js';
import * as os from '@/os.js'; import * as os from '@/os.js';
import { instance } from '@/instance.js'; import { instance } from '@/instance.js';
import { host } from '@@/js/config.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { $i } from '@/i.js'; import { $i } from '@/i.js';
@ -146,8 +146,8 @@ export function openInstanceMenu(ev: MouseEvent) {
menuItems.push({ menuItems.push({
text: i18n.ts._initialTutorial.launchTutorial, text: i18n.ts._initialTutorial.launchTutorial,
icon: 'ti ti-presentation', icon: 'ti ti-presentation',
action: () => { action: async () => {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkTutorialDialog.vue')), {}, { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkTutorialDialog.vue').then(x => x.default), {}, {
closed: () => dispose(), closed: () => dispose(),
}); });
}, },

View File

@ -71,8 +71,8 @@ const otherNavItemIndicated = computed<boolean>(() => {
return false; return false;
}); });
function more(ev: MouseEvent) { async function more(ev: MouseEvent) {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkLaunchPad.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkLaunchPad.vue').then(x => x.default), {
anchorElement: ev.currentTarget ?? ev.target, anchorElement: ev.currentTarget ?? ev.target,
anchor: { x: 'center', y: 'bottom' }, anchor: { x: 'center', y: 'bottom' },
}, { }, {

View File

@ -176,10 +176,10 @@ function openAccountMenu(ev: MouseEvent) {
}, ev); }, ev);
} }
function more(ev: MouseEvent) { async function more(ev: MouseEvent) {
const target = getHTMLElementOrNull(ev.currentTarget ?? ev.target); const target = getHTMLElementOrNull(ev.currentTarget ?? ev.target);
if (!target) return; if (!target) return;
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkLaunchPad.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkLaunchPad.vue').then(x => x.default), {
anchorElement: target, anchorElement: target,
}, { }, {
closed: () => dispose(), closed: () => dispose(),

View File

@ -72,7 +72,7 @@ async function setAntenna() {
if (canceled || antenna == null) return; if (canceled || antenna == null) return;
if (antenna === '_CREATE_') { if (antenna === '_CREATE_') {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkAntennaEditorDialog.vue')), {}, { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkAntennaEditorDialog.vue').then(x => x.default), {}, {
created: (newAntenna: MisskeyEntities.Antenna) => { created: (newAntenna: MisskeyEntities.Antenna) => {
antennasCache.delete(); antennasCache.delete();
updateColumn(props.column.id, { updateColumn(props.column.id, {

View File

@ -27,8 +27,8 @@ const props = defineProps<{
const notificationsComponent = useTemplateRef('notificationsComponent'); const notificationsComponent = useTemplateRef('notificationsComponent');
function func() { async function func() {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkNotificationSelectWindow.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkNotificationSelectWindow.vue').then(x => x.default), {
excludeTypes: props.column.excludeTypes, excludeTypes: props.column.excludeTypes,
}, { }, {
done: async (res) => { done: async (res) => {

View File

@ -172,8 +172,8 @@ export function chooseFileFromPcAndUpload(
export function chooseDriveFile(options: { export function chooseDriveFile(options: {
multiple?: boolean; multiple?: boolean;
} = {}): Promise<Misskey.entities.DriveFile[]> { } = {}): Promise<Misskey.entities.DriveFile[]> {
return new Promise(resolve => { return new Promise(async resolve => {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkDriveFileSelectDialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkDriveFileSelectDialog.vue').then(x => x.default), {
multiple: options.multiple ?? false, multiple: options.multiple ?? false,
}, { }, {
done: files => { done: files => {
@ -286,8 +286,8 @@ export async function createCroppedImageDriveFileFromImageDriveFile(imageDriveFi
} }
export async function selectDriveFolder(initialFolder: Misskey.entities.DriveFolder['id'] | null): Promise<Misskey.entities.DriveFolder[]> { export async function selectDriveFolder(initialFolder: Misskey.entities.DriveFolder['id'] | null): Promise<Misskey.entities.DriveFolder[]> {
return new Promise(resolve => { return new Promise(async resolve => {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkDriveFolderSelectDialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkDriveFolderSelectDialog.vue').then(x => x.default), {
initialFolder, initialFolder,
}, { }, {
done: folders => { done: folders => {

View File

@ -28,8 +28,8 @@ function rename(file: Misskey.entities.DriveFile) {
}); });
} }
function describe(file: Misskey.entities.DriveFile) { async function describe(file: Misskey.entities.DriveFile) {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkFileCaptionEditWindow.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkFileCaptionEditWindow.vue').then(x => x.default), {
default: file.comment ?? '', default: file.comment ?? '',
file: file, file: file,
}, { }, {

View File

@ -64,7 +64,7 @@ export function getEmbedCode(path: string, params?: EmbedParams): string {
* *
* getEmbedCode 使 * getEmbedCode 使
*/ */
export function genEmbedCode(entity: EmbeddableEntity, id: string, params?: EmbedParams) { export async function genEmbedCode(entity: EmbeddableEntity, id: string, params?: EmbedParams) {
const _params = { ...params }; const _params = { ...params };
if (embedRouteWithScrollbar.includes(entity) && _params.maxHeight == null) { if (embedRouteWithScrollbar.includes(entity) && _params.maxHeight == null) {
@ -75,7 +75,7 @@ export function genEmbedCode(entity: EmbeddableEntity, id: string, params?: Embe
if (window.innerWidth < MOBILE_THRESHOLD) { if (window.innerWidth < MOBILE_THRESHOLD) {
copyToClipboard(getEmbedCode(`/embed/${entity}/${id}`, _params)); copyToClipboard(getEmbedCode(`/embed/${entity}/${id}`, _params));
} else { } else {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkEmbedCodeGenDialog.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkEmbedCodeGenDialog.vue').then(x => x.default), {
entity, entity,
id, id,
params: _params, params: _params,

View File

@ -135,12 +135,12 @@ export function getAbuseNoteMenu(note: Misskey.entities.Note, text: string): Men
return { return {
icon: 'ti ti-exclamation-circle', icon: 'ti ti-exclamation-circle',
text, text,
action: (): void => { action: async (): Promise<void> => {
const localUrl = `${url}/notes/${note.id}`; const localUrl = `${url}/notes/${note.id}`;
let noteInfo = ''; let noteInfo = '';
if (note.url ?? note.uri != null) noteInfo = `Note: ${note.url ?? note.uri}\n`; if (note.url ?? note.uri != null) noteInfo = `Note: ${note.url ?? note.uri}\n`;
noteInfo += `Local Note: ${localUrl}\n`; noteInfo += `Local Note: ${localUrl}\n`;
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkAbuseReportWindow.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkAbuseReportWindow.vue').then(x => x.default), {
user: note.user, user: note.user,
initialComment: `${noteInfo}-----\n`, initialComment: `${noteInfo}-----\n`,
}, { }, {

View File

@ -94,8 +94,8 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: Router
}); });
} }
function reportAbuse() { async function reportAbuse() {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkAbuseReportWindow.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkAbuseReportWindow.vue').then(x => x.default), {
user: user, user: user,
}, { }, {
closed: () => dispose(), closed: () => dispose(),

View File

@ -3,11 +3,10 @@
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { defineAsyncComponent } from 'vue';
import { $i } from '@/i.js'; import { $i } from '@/i.js';
import { instance } from '@/instance.js'; import { instance } from '@/instance.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
import { popup } from '@/os.js'; import { popupAsyncWithDialog } from '@/os.js';
export type OpenOnRemoteOptions = { export type OpenOnRemoteOptions = {
/** /**
@ -45,7 +44,7 @@ export type OpenOnRemoteOptions = {
params: Record<string, string>; params: Record<string, string>;
}; };
export function pleaseLogin(opts: { export async function pleaseLogin(opts: {
path?: string; path?: string;
message?: string; message?: string;
openOnRemote?: OpenOnRemoteOptions; openOnRemote?: OpenOnRemoteOptions;
@ -59,7 +58,7 @@ export function pleaseLogin(opts: {
_openOnRemote = opts.openOnRemote; _openOnRemote = opts.openOnRemote;
} }
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkSigninDialog.vue')), { const { dispose } = await popupAsyncWithDialog(import('@/components/MkSigninDialog.vue').then(x => x.default), {
autoSet: true, autoSet: true,
message: opts.message ?? (_openOnRemote ? i18n.ts.signinOrContinueOnRemote : i18n.ts.signinRequired), message: opts.message ?? (_openOnRemote ? i18n.ts.signinOrContinueOnRemote : i18n.ts.signinRequired),
openOnRemote: _openOnRemote, openOnRemote: _openOnRemote,

View File

@ -54,8 +54,8 @@ const { widgetProps, configure, save } = useWidgetPropsManager(name,
emit, emit,
); );
const configureNotification = () => { const configureNotification = async () => {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkNotificationSelectWindow.vue')), { const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkNotificationSelectWindow.vue').then(x => x.default), {
excludeTypes: widgetProps.excludeTypes, excludeTypes: widgetProps.excludeTypes,
}, { }, {
done: async (res) => { done: async (res) => {