From 3bed093344cbe7e86e516ad86df1b6e7c484930e Mon Sep 17 00:00:00 2001 From: Lhcfl Date: Wed, 24 Apr 2024 11:36:56 +0800 Subject: [PATCH] fix: Visible users are not automatically filled when editing --- packages/client/src/components/MkVisibility.vue | 4 ++-- packages/client/src/scripts/get-note-menu.ts | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/client/src/components/MkVisibility.vue b/packages/client/src/components/MkVisibility.vue index 160dba46f4..1feafb21f1 100644 --- a/packages/client/src/components/MkVisibility.vue +++ b/packages/client/src/components/MkVisibility.vue @@ -59,7 +59,7 @@ if ( ) { useTooltip(specified, async (showing) => { const users = await os.api("users/show", { - userIds: props.note.visibleUserIds, + userIds: props.note.visibleUserIds!, limit: 10, }); @@ -68,7 +68,7 @@ if ( { showing, users, - count: props.note.visibleUserIds.length, + count: props.note.visibleUserIds!.length, targetElement: specified.value, }, {}, diff --git a/packages/client/src/scripts/get-note-menu.ts b/packages/client/src/scripts/get-note-menu.ts index 1bc2941acc..2945cb16b3 100644 --- a/packages/client/src/scripts/get-note-menu.ts +++ b/packages/client/src/scripts/get-note-menu.ts @@ -49,11 +49,22 @@ export function getNoteMenu(props: { }); } + async function getVisibleUsers() { + if (appearNote.visibleUserIds && appearNote.visibleUserIds.length > 0) { + const users = await os.api("users/show", { + userIds: appearNote.visibleUserIds, + }); + return users; + } else { + return undefined; + } + } + function delEdit(): void { os.confirm({ type: "warning", text: i18n.ts.deleteAndEditConfirm, - }).then(({ canceled }) => { + }).then(async ({ canceled }) => { if (canceled) return; os.api("notes/delete", { @@ -65,17 +76,19 @@ export function getNoteMenu(props: { renote: appearNote.renote, reply: appearNote.reply, channel: appearNote.channel, + initialVisibleUsers: await getVisibleUsers(), }); }); } - function edit(): void { + async function edit() { os.post({ initialNote: appearNote, renote: appearNote.renote, reply: appearNote.reply, channel: appearNote.channel, editId: appearNote.id, + initialVisibleUsers: await getVisibleUsers(), }); }