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) => {
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,
},
{},

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 {
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(),
});
}