Skip to content

Commit

Permalink
Fixing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmitrevski committed Oct 31, 2023
1 parent 355253e commit a810da0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<MessageReactionType> {
Set(message.currentUserReactions.map(\.type))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand All @@ -36,10 +45,8 @@ open class ReactionsOverlayViewModel: ObservableObject, ChatMessageControllerDel
didChangeMessage change: EntityChange<ChatMessage>
) {
if let message = controller.message {
if message.reactionScoresId != self.message.reactionScoresId {
withAnimation {
self.message = message
}
withAnimation {
self.message = message
}
}
}
Expand Down

0 comments on commit a810da0

Please sign in to comment.