mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-06 20:16:57 +00:00
merge: Fix polls not rendering properly in Schedule List (!990)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/990 Closes #1049 Approved-by: Hazelnoot <acomputerdog@gmail.com> Approved-by: dakkar <dakkar@thenautilus.net>
This commit is contained in:
commit
0d6b52ab3a
1 changed files with 18 additions and 0 deletions
|
@ -133,6 +133,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
renote, reply,
|
||||
renoteId: item.note.renote,
|
||||
replyId: item.note.reply,
|
||||
poll: item.note.poll ? await this.fillPoll(item.note.poll) : undefined,
|
||||
},
|
||||
};
|
||||
}));
|
||||
|
@ -155,4 +156,21 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Pulled from NoteEntityService and modified to work with MiNoteSchedule
|
||||
// originally planned to use directly from NoteEntityService but since the poll doesn't actually exist yet that doesn't work
|
||||
@bindThis
|
||||
private async fillPoll(poll: { multiple: boolean; choices: string[]; expiresAt: string | null }) {
|
||||
const choices = poll.choices.map(c => ({
|
||||
text: c,
|
||||
votes: 0, // Default to 0 as there will never be any registered votes while scheduled
|
||||
isVoted: false, // Default to false as the author can't vote anyways since the poll does not exist in the repo yet
|
||||
}));
|
||||
|
||||
return {
|
||||
multiple: poll.multiple,
|
||||
expiresAt: poll.expiresAt ? new Date(poll.expiresAt).toISOString() : null,
|
||||
choices,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue