[backend/core] Fix editing of polls with no recorded votes
This commit is contained in:
parent
1fae913a32
commit
ea8ff6495c
1 changed files with 3 additions and 3 deletions
|
@ -466,7 +466,7 @@ public class NoteService(
|
|||
await db.PollVotes.Where(p => p.Note == note).ExecuteDeleteAsync();
|
||||
note.Poll.Choices = poll.Choices;
|
||||
note.Poll.Multiple = poll.Multiple;
|
||||
note.Poll.Votes = poll.Votes.Count != poll.Choices.Count
|
||||
note.Poll.Votes = poll.Votes == null! || poll.Votes.Count != poll.Choices.Count
|
||||
? poll.Choices.Select(_ => 0).ToList()
|
||||
: poll.Votes;
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ public class NoteService(
|
|||
poll.UserId = note.User.Id;
|
||||
poll.UserHost = note.UserHost;
|
||||
poll.NoteVisibility = note.Visibility;
|
||||
if (poll.Votes.Count != poll.Choices.Count)
|
||||
if (poll.Votes == null! || poll.Votes.Count != poll.Choices.Count)
|
||||
poll.Votes = poll.Choices.Select(_ => 0).ToList();
|
||||
|
||||
await db.AddAsync(poll);
|
||||
|
|
Loading…
Add table
Reference in a new issue