Skip to content

Commit 9a09e67

Browse files
Added config for disabling reaction animations
1 parent d2764ea commit 9a09e67

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Sources/StreamChatSwiftUI/ChatChannel/ChatChannelViewModel.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,11 @@ open class ChatChannelViewModel: ObservableObject, MessagesDataSource {
422422
|| message.type == .ephemeral
423423
|| !message.linkAttachments.isEmpty {
424424
skipChanges = false
425-
if index.row < messages.count && message.reactionScoresId != messages[index.row].reactionScoresId {
425+
if index.row < messages.count
426+
&& (
427+
message.reactionScoresId != messages[index.row].reactionScoresId
428+
&& utils.messageListConfig.messageDisplayOptions.shouldAnimateReactions
429+
) {
426430
animateChanges = message.linkAttachments.isEmpty
427431
}
428432
}

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListConfig.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public struct MessageDisplayOptions {
8383
let minimumSwipeGestureDistance: CGFloat
8484
let currentUserMessageTransition: AnyTransition
8585
let otherUserMessageTransition: AnyTransition
86+
let shouldAnimateReactions: Bool
8687
var messageLinkDisplayResolver: (ChatMessage) -> [NSAttributedString.Key: Any]
8788

8889
public init(
@@ -95,6 +96,7 @@ public struct MessageDisplayOptions {
9596
minimumSwipeGestureDistance: CGFloat = 10,
9697
currentUserMessageTransition: AnyTransition = .identity,
9798
otherUserMessageTransition: AnyTransition = .identity,
99+
shouldAnimateReactions: Bool = true,
98100
messageLinkDisplayResolver: @escaping (ChatMessage) -> [NSAttributedString.Key: Any] = MessageDisplayOptions
99101
.defaultLinkDisplay
100102
) {
@@ -108,6 +110,7 @@ public struct MessageDisplayOptions {
108110
self.otherUserMessageTransition = otherUserMessageTransition
109111
self.messageLinkDisplayResolver = messageLinkDisplayResolver
110112
self.lastInGroupHeaderSize = lastInGroupHeaderSize
113+
self.shouldAnimateReactions = shouldAnimateReactions
111114
}
112115

113116
public static var defaultLinkDisplay: (ChatMessage) -> [NSAttributedString.Key: Any] {

0 commit comments

Comments
 (0)