fix poll change detection

This commit is contained in:
Hazelnoot 2025-11-14 19:10:16 -05:00
parent a9a0327204
commit 4776292cee

View file

@ -477,12 +477,9 @@ export class NoteEditService implements OnApplicationShutdown {
const filesChanged = oldNote.fileIds.length || data.files?.length; const filesChanged = oldNote.fileIds.length || data.files?.length;
const oldPoll = await this.pollsRepository.findOneBy({ noteId: oldNote.id }); const oldPoll = await this.pollsRepository.findOneBy({ noteId: oldNote.id });
const oldPollData = oldPoll ? { choices: oldPoll.choices, multiple: oldPoll.multiple, expiresAt: oldPoll.expiresAt?.toISOString() ?? null } : null;
const oldPollData = oldPoll ? { choices: oldPoll.choices, multiple: oldPoll.multiple, expiresAt: oldPoll.expiresAt } : null; const newPollData = data.poll ? { choices: data.poll.choices, multiple: data.poll.multiple, expiresAt: data.poll.expiresAt ?? null } : null;
const pollChanged = const pollChanged = data.poll !== undefined && JSON.stringify(oldPollData) !== JSON.stringify(newPollData);
(data.poll == null && oldPoll != null) ||
(data.poll != null && oldPoll == null) ||
(data.poll != null && oldPoll != null && JSON.stringify(data.poll) !== JSON.stringify(oldPollData));
if (Object.keys(update).length > 0 || filesChanged || pollChanged) { if (Object.keys(update).length > 0 || filesChanged || pollChanged) {
const exists = await this.noteEditsRepository.findOneBy({ noteId: oldNote.id }); const exists = await this.noteEditsRepository.findOneBy({ noteId: oldNote.id });