diff --git a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/BottomReactionsView.swift b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/BottomReactionsView.swift index 8696ae95..9dce50d1 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/BottomReactionsView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/BottomReactionsView.swift @@ -133,6 +133,10 @@ struct BottomReactionsView: View { viewModel.message } + private var reactions: [MessageReactionType] { + viewModel.reactions + } + private var cornersForAddReactionButton: UIRectCorner { (message.isSentByCurrentUser && showsAllInfo) ? [.bottomLeft, .bottomRight, .topLeft] : .allCorners @@ -153,13 +157,6 @@ struct BottomReactionsView: View { } } - private var reactions: [MessageReactionType] { - message.reactionScores.keys.filter { reactionType in - (message.reactionScores[reactionType] ?? 0) > 0 - } - .sorted(by: utils.sortReactions) - } - private var userReactionIDs: Set { Set(message.currentUserReactions.map(\.type)) } diff --git a/Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayViewModel.swift b/Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayViewModel.swift index 15216683..3de0d218 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayViewModel.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayViewModel.swift @@ -8,9 +8,18 @@ import SwiftUI open class ReactionsOverlayViewModel: ObservableObject, ChatMessageControllerDelegate { @Injected(\.chatClient) private var chatClient + @Injected(\.utils) private var utils - @Published public var message: ChatMessage + @Published public var message: ChatMessage { + didSet { + self.reactions = message.reactionScores.keys.filter { reactionType in + (message.reactionScores[reactionType] ?? 0) > 0 + } + .sorted(by: utils.sortReactions) + } + } @Published public var errorShown = false + @Published public var reactions = [MessageReactionType]() private var messageController: ChatMessageController? @@ -36,10 +45,8 @@ open class ReactionsOverlayViewModel: ObservableObject, ChatMessageControllerDel didChangeMessage change: EntityChange ) { if let message = controller.message { - if message.reactionScoresId != self.message.reactionScoresId { - withAnimation { - self.message = message - } + withAnimation { + self.message = message } } }