fix: Visible users are not automatically filled when editing

This commit is contained in:
Lhcfl 2024-04-24 11:36:56 +08:00
parent 243adaaa0d
commit 3bed093344
2 changed files with 17 additions and 4 deletions

View file

@ -59,7 +59,7 @@ if (
) { ) {
useTooltip(specified, async (showing) => { useTooltip(specified, async (showing) => {
const users = await os.api("users/show", { const users = await os.api("users/show", {
userIds: props.note.visibleUserIds, userIds: props.note.visibleUserIds!,
limit: 10, limit: 10,
}); });
@ -68,7 +68,7 @@ if (
{ {
showing, showing,
users, users,
count: props.note.visibleUserIds.length, count: props.note.visibleUserIds!.length,
targetElement: specified.value, targetElement: specified.value,
}, },
{}, {},

View file

@ -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 { function delEdit(): void {
os.confirm({ os.confirm({
type: "warning", type: "warning",
text: i18n.ts.deleteAndEditConfirm, text: i18n.ts.deleteAndEditConfirm,
}).then(({ canceled }) => { }).then(async ({ canceled }) => {
if (canceled) return; if (canceled) return;
os.api("notes/delete", { os.api("notes/delete", {
@ -65,17 +76,19 @@ export function getNoteMenu(props: {
renote: appearNote.renote, renote: appearNote.renote,
reply: appearNote.reply, reply: appearNote.reply,
channel: appearNote.channel, channel: appearNote.channel,
initialVisibleUsers: await getVisibleUsers(),
}); });
}); });
} }
function edit(): void { async function edit() {
os.post({ os.post({
initialNote: appearNote, initialNote: appearNote,
renote: appearNote.renote, renote: appearNote.renote,
reply: appearNote.reply, reply: appearNote.reply,
channel: appearNote.channel, channel: appearNote.channel,
editId: appearNote.id, editId: appearNote.id,
initialVisibleUsers: await getVisibleUsers(),
}); });
} }