From 5f93e5e0d1df805b312b75b707cc69634ba3c9eb Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 15 May 2025 23:12:57 +0200 Subject: [PATCH 1/2] fix(core): Fallback to loading channel at last read date when loadChannelAtMessage fails --- .../lib/src/stream_channel.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart index 068cb5518..ed076b608 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel.dart @@ -508,7 +508,16 @@ class StreamChannelState extends State { // Load the channel at the last read message if available. if (currentUserRead.lastReadMessageId case final lastReadMessageId?) { - return loadChannelAtMessage(lastReadMessageId); + try { + return await loadChannelAtMessage(lastReadMessageId); + } catch (e) { + // If the loadChannelAtMessage for any reason fails, we fallback to + // loading the channel at the last read date. + // + // One example of this is when the channel becomes too large and + // exceeds a certain threshold (I believe it's a 1000 members) it + // can't update the readstate anymore for each individual member. + } } // Otherwise, load the channel at the last read date. From 55690956af28b993abc1c19a1e867391f03893c8 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 15 May 2025 23:16:16 +0200 Subject: [PATCH 2/2] chore: update CHANGELOG.md --- packages/stream_chat_flutter_core/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/stream_chat_flutter_core/CHANGELOG.md b/packages/stream_chat_flutter_core/CHANGELOG.md index 6cbd44fad..156009d6e 100644 --- a/packages/stream_chat_flutter_core/CHANGELOG.md +++ b/packages/stream_chat_flutter_core/CHANGELOG.md @@ -1,5 +1,11 @@ ## Upcoming +🐞 Fixed + +- Fixed an issue with `StreamChannel` where loading channel at `lastReadMessageId` might fail + if the channel exceeds the member threshold. This is now handled gracefully by falling back to loading + the channel at the `lastRead` date. + 🔄 Changed - Updated `freezed_annotation` dependency to `">=2.4.1 <4.0.0"`.