try to fix disposed errors when ending poll

This commit is contained in:
Henry Hiles 2026-11-03 14:26:53 -05:00
commit 2580cc8c1c
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -75,6 +75,7 @@ class const PollRenderer(final Event event, final PollStart poll, {super.key})
) async {
pending.value = action;
await send().onError(showError);
if (!context.mounted) return;
// Otherwise the old votes show until they're refetched
await ref.read(votesProvider.future).onError((_, _) => const .new());
if (context.mounted) pending.value = null;