From 596b06a9628675d5960d375fb69604d05dde119c Mon Sep 17 00:00:00 2001 From: pancakes Date: Tue, 18 Feb 2025 21:21:25 +1000 Subject: [PATCH] [frontend/components] Don't allow empty poll choices --- Iceshrimp.Frontend/Components/Compose.razor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Iceshrimp.Frontend/Components/Compose.razor b/Iceshrimp.Frontend/Components/Compose.razor index bc8a7690..73aa2ac9 100644 --- a/Iceshrimp.Frontend/Components/Compose.razor +++ b/Iceshrimp.Frontend/Components/Compose.razor @@ -241,7 +241,7 @@ } private bool SendingDisabled() => - NoteLength - ((NoteDraft.Cw?.Length ?? 0) + NoteDraft.Text.Length) < 0 || UploadingFiles != 0; + NoteLength - ((NoteDraft.Cw?.Length ?? 0) + NoteDraft.Text.Length) < 0 || UploadingFiles != 0 || NoteDraft.Poll != null && PollChoices.Count(p => !string.IsNullOrWhiteSpace(p.Value)) < 2; private async Task HandleKeyDown(KeyboardEventArgs e) { @@ -403,7 +403,7 @@ if (NoteDraft.Poll != null) { - NoteDraft.Poll.Choices = PollChoices.Select(p => p.Value).ToList(); + NoteDraft.Poll.Choices = PollChoices.Select(p => p.Value).Where(p => !string.IsNullOrWhiteSpace(p)).ToList(); NoteDraft.Poll.ExpiresAt = PollExpires switch { PollExpire.ExpiresAt => PollExpireTime.ToUniversalTime(), @@ -487,6 +487,7 @@ private void AddPollChoice() { + if (string.IsNullOrWhiteSpace(PollEntry)) return; PollChoices.Add(new Choice { Value = PollEntry }); PollEntry = ""; }