From 9586209d3c88d5179ad5aed3a283d40e98f734df Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Wed, 2 Feb 2022 18:47:05 +0530 Subject: [PATCH 1/2] fix(llc): fix ChannelState copyWith with respect to pinnedMessages default value. Signed-off-by: xsahil03x --- .../stream_chat/lib/src/core/models/channel_state.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat/lib/src/core/models/channel_state.dart b/packages/stream_chat/lib/src/core/models/channel_state.dart index fb5fc64f..3ddc2b68 100644 --- a/packages/stream_chat/lib/src/core/models/channel_state.dart +++ b/packages/stream_chat/lib/src/core/models/channel_state.dart @@ -7,6 +7,8 @@ import 'package:stream_chat/src/core/models/user.dart'; part 'channel_state.g.dart'; +const _emptyPinnedMessages = []; + /// The class that contains the information about a channel @JsonSerializable() class ChannelState { @@ -15,7 +17,7 @@ class ChannelState { this.channel, this.messages = const [], this.members = const [], - this.pinnedMessages = const [], + this.pinnedMessages = _emptyPinnedMessages, this.watcherCount, this.watchers = const [], this.read = const [], @@ -63,7 +65,11 @@ class ChannelState { channel: channel ?? this.channel, messages: messages ?? this.messages, members: members ?? this.members, - pinnedMessages: pinnedMessages ?? this.pinnedMessages, + // Hack to avoid using the default value in case nothing is provided. + // FIXME: Use non-nullable by default instead of empty list. + pinnedMessages: pinnedMessages == _emptyPinnedMessages + ? this.pinnedMessages + : pinnedMessages ?? _emptyPinnedMessages, watcherCount: watcherCount ?? this.watcherCount, watchers: watchers ?? this.watchers, read: read ?? this.read, From 97f380454dd09221de73ca390254372591b54328 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Wed, 2 Feb 2022 18:48:38 +0530 Subject: [PATCH 2/2] chore(llc): update CHANGELOG.md Signed-off-by: xsahil03x --- packages/stream_chat/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/stream_chat/CHANGELOG.md b/packages/stream_chat/CHANGELOG.md index 809fb3a3..d14df3a0 100644 --- a/packages/stream_chat/CHANGELOG.md +++ b/packages/stream_chat/CHANGELOG.md @@ -8,6 +8,7 @@ - [[#871]](https://github.com/GetStream/stream-chat-flutter/issues/871) Fixed thread message deletion. - [[#846]](https://github.com/GetStream/stream-chat-flutter/issues/846) Fixed `message.ownReactions` getting truncated when receiving a reaction event. - Add check for invalid image URLs +- Fix `channelState.pinnedMessagesStream` getting reset to `0` after a channel update. 🔄 Changed