Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/stream_chat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Upcoming

🐞 Fixed

- Fixed pinned message stream issue.

## 3.4.0

🐞 Fixed
Expand Down
21 changes: 11 additions & 10 deletions packages/stream_chat/lib/src/client/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,8 @@ class Channel {

/// Remove the ban for the user with given [userID] in the channel.
@Deprecated(
"Use 'unbanMember' instead. This method will be removed in v4.0.0")
"Use 'unbanMember' instead. This method will be removed in v4.0.0",
)
Future<EmptyResponse> unbanUser(String userID) => unbanMember(userID);

/// Remove the ban for the member with given [userID] in the channel.
Expand Down Expand Up @@ -1736,15 +1737,6 @@ class ChannelClientState {
ownReactions: oldMessage?.ownReactions,
);
addMessage(message);

if (message.pinned) {
_channelState = _channelState.copyWith(
pinnedMessages: [
..._channelState.pinnedMessages,
message,
],
);
}
}));
}

Expand Down Expand Up @@ -1796,11 +1788,20 @@ class ChannelClientState {
newMessages.add(message);
}

final _originalPinned = _channelState.pinnedMessages;
Comment thread
d3xvn marked this conversation as resolved.
Outdated

if (message.pinned) {
_originalPinned.add(message);
} else {
_originalPinned.removeWhere((e) => e.id == message.id);
}

_channelState = _channelState.copyWith(
messages: newMessages..sort(_sortByCreatedAt),
channel: _channelState.channel?.copyWith(
lastMessageAt: message.createdAt,
),
pinnedMessages: _originalPinned,
);
}

Expand Down