try to fix disposed errors when ending poll
This commit is contained in:
parent
2fc5a9bf85
commit
2580cc8c1c
2 changed files with 4 additions and 3 deletions
|
|
@ -466,6 +466,8 @@ class RoomChatController(final ChatParams info)
|
||||||
EventType type,
|
EventType type,
|
||||||
Content content,
|
Content content,
|
||||||
) async {
|
) async {
|
||||||
|
// The end event lands in the timeline and rebuilds this, so no ref after awaiting
|
||||||
|
final rooms = ref.read(RoomsController.provider.notifier);
|
||||||
final event = await ref
|
final event = await ref
|
||||||
.read(ClientController.provider.notifier)
|
.read(ClientController.provider.notifier)
|
||||||
.sendEvent(
|
.sendEvent(
|
||||||
|
|
@ -481,9 +483,7 @@ class RoomChatController(final ChatParams info)
|
||||||
|
|
||||||
if (event.sendFailed) throw Exception(event.sendError);
|
if (event.sendFailed) throw Exception(event.sendError);
|
||||||
|
|
||||||
await ref
|
await rooms.awaitEvent(info.roomId, event.eventId);
|
||||||
.read(RoomsController.provider.notifier)
|
|
||||||
.awaitEvent(info.roomId, event.eventId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An empty [answers] removes the vote.
|
/// An empty [answers] removes the vote.
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ class const PollRenderer(final Event event, final PollStart poll, {super.key})
|
||||||
) async {
|
) async {
|
||||||
pending.value = action;
|
pending.value = action;
|
||||||
await send().onError(showError);
|
await send().onError(showError);
|
||||||
|
if (!context.mounted) return;
|
||||||
// Otherwise the old votes show until they're refetched
|
// Otherwise the old votes show until they're refetched
|
||||||
await ref.read(votesProvider.future).onError((_, _) => const .new());
|
await ref.read(votesProvider.future).onError((_, _) => const .new());
|
||||||
if (context.mounted) pending.value = null;
|
if (context.mounted) pending.value = null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue