[frontend/components] Display error notice when poll voting fails

This commit is contained in:
pancakes 2025-02-23 12:00:24 +10:00
parent 8da7bf7cf7
commit ace2c44279
No known key found for this signature in database
GPG key ID: ED53D426432B861B

View file

@ -1,8 +1,11 @@
@using Iceshrimp.Frontend.Core.Miscellaneous
@using Iceshrimp.Frontend.Core.Services
@using Iceshrimp.Frontend.Core.Services.NoteStore @using Iceshrimp.Frontend.Core.Services.NoteStore
@using Iceshrimp.Frontend.Localization @using Iceshrimp.Frontend.Localization
@using Iceshrimp.Shared.Schemas.Web @using Iceshrimp.Shared.Schemas.Web
@using Microsoft.Extensions.Localization @using Microsoft.Extensions.Localization
@inject NoteActions NoteActions; @inject GlobalComponentSvc Global;
@inject NoteActions NoteActions;
@inject IStringLocalizer<Localization> Loc; @inject IStringLocalizer<Localization> Loc;
<div class="poll"> <div class="poll">
@ -84,6 +87,13 @@
{ {
if (!CanVote()) return; if (!CanVote()) return;
await NoteActions.AddPollVoteAsync(Poll, Choices); try
{
await NoteActions.AddPollVoteAsync(Poll, Choices);
}
catch (ApiException e)
{
await Global.NoticeDialog?.Display(e.Response.Message ?? Loc["An unknown error occurred while voting"], NoticeDialog.NoticeType.Error)!;
}
} }
} }