add more mounted checks to room chat controller

This commit is contained in:
Henry Hiles 2026-11-13 00:02:22 -05:00
commit 2b0e8fb819
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -295,6 +295,7 @@ class RoomChatController(final ChatParams info)
: null, : null,
), ),
); );
if (!ref.mounted) return;
if (response.events.isEmpty) { if (response.events.isEmpty) {
state = .data(chat); state = .data(chat);
@ -333,6 +334,7 @@ class RoomChatController(final ChatParams info)
: chat!.historicalData!.start, : chat!.historicalData!.start,
), ),
); );
if (!ref.mounted) return;
ref ref
.read(RoomsController.provider.notifier) .read(RoomsController.provider.notifier)
@ -345,6 +347,7 @@ class RoomChatController(final ChatParams info)
final rootRowId = direction == .backward final rootRowId = direction == .backward
? await threadRootBefore(paginationResponse) ? await threadRootBefore(paginationResponse)
: null; : null;
if (!ref.mounted) return;
final eventRowIds = [ final eventRowIds = [
?rootRowId, ?rootRowId,
...(direction == .forward ...(direction == .forward
@ -383,6 +386,7 @@ class RoomChatController(final ChatParams info)
); );
} }
} catch (_) { } catch (_) {
if (!ref.mounted) return;
state = .data(chat); state = .data(chat);
rethrow; rethrow;
} }