Skip to content

Commit 5bd608b

Browse files
authored
fix(core): Fallback to loading channel at last read date when loadChannelAtMessage fails (#2253)
1 parent 6800319 commit 5bd608b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

packages/stream_chat_flutter_core/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## Upcoming
22

3+
🐞 Fixed
4+
5+
- Fixed an issue with `StreamChannel` where loading channel at `lastReadMessageId` might fail
6+
if the channel exceeds the member threshold. This is now handled gracefully by falling back to loading
7+
the channel at the `lastRead` date.
8+
39
🔄 Changed
410

511
- Updated `freezed_annotation` dependency to `">=2.4.1 <4.0.0"`.

packages/stream_chat_flutter_core/lib/src/stream_channel.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,16 @@ class StreamChannelState extends State<StreamChannel> {
508508

509509
// Load the channel at the last read message if available.
510510
if (currentUserRead.lastReadMessageId case final lastReadMessageId?) {
511-
return loadChannelAtMessage(lastReadMessageId);
511+
try {
512+
return await loadChannelAtMessage(lastReadMessageId);
513+
} catch (e) {
514+
// If the loadChannelAtMessage for any reason fails, we fallback to
515+
// loading the channel at the last read date.
516+
//
517+
// One example of this is when the channel becomes too large and
518+
// exceeds a certain threshold (I believe it's a 1000 members) it
519+
// can't update the readstate anymore for each individual member.
520+
}
512521
}
513522

514523
// Otherwise, load the channel at the last read date.

0 commit comments

Comments
 (0)