stream-chat-swift icon indicating copy to clipboard operation
stream-chat-swift copied to clipboard

Update Message flickering

Open borut-t opened this issue 1 year ago • 4 comments

What did you do?

let controller = chatService.client.messageController(cid: channelId, messageId: selectedMessageId)
var existingData = controller.message?.extraData ?? [:]
existingData["emojis"] = .dictionary([selectedEmoji.value: .number(count)])
controller.editMessage(text: controller.message!.text, extraData: existingData)

What did you expect to happen?

Message not to flicker and reset while updating it.

What happened instead?

When I update extraData on message, the newlyAdded data is rendered immediately. But just after that it disappears and re-appears again.

I'm using custom message view to have a custom layout.

...
func makeMessageContainerView(channel: ChatChannel, message: ChatMessage, width: CGFloat?, showsAllInfo: Bool, 
                                  isInThread: Bool, scrolledId: Binding<String?>, quotedMessage: Binding<ChatMessage?>,
                                  onLongPress: @escaping (MessageDisplayInfo) -> Void, isLast: Bool) -> some View {
      CustomMessageView(message: message, showsAllInfo: showsAllInfo)
}

...
struct CustomMessageView {
...
HStack(alignment: .center, spacing: 4) {
  if let emojis = message.extraData["emojis"]?.dictionaryValue {
    ForEach(Array(emojis.keys), id: \.self) { key in
      emojiButton ...
    }
  }
}
...
}

GetStream Environment

GetStream Chat version: 4.39 GetStream Chat frameworks: StreamChat, StreamChatSwiftUI iOS version: 17 Swift version: 5.9 Xcode version: 15 Device: iPhone

Additional context

https://github.com/GetStream/stream-chat-swiftui/assets/677166/595f7903-545d-4493-bcbc-9a707da8bc4d

borut-t avatar Oct 25 '23 06:10 borut-t

Hey @borut-t,

Thanks for reporting, we will look into it.

martinmitrevski avatar Oct 25 '23 13:10 martinmitrevski

Hey @borut-t,

I think the issue here is that you re-create a message controller at the moment the reaction is applied. Can you please check if the method client.messageController(cid: channelId, messageId: selectedMessageId) is called only once for each message view?

martinmitrevski avatar Oct 26 '23 11:10 martinmitrevski

Hey @borut-t,

I think the issue here is that you re-create a message controller at the moment the reaction is applied. Can you please check if the method client.messageController(cid: channelId, messageId: selectedMessageId) is called only once for each message view?

It is called only once yes. Although I cannot assure you that since I've changed the logic and now I'm calling addReaction method instead and the result is better or it works as expected.

I would suggest you implement a method that could alter extraData only, without the need of supplying a text.

borut-t avatar Oct 27 '23 19:10 borut-t

Moving this to our low-level client repo, where the issue is happening.

martinmitrevski avatar Oct 30 '23 12:10 martinmitrevski

Hi @borut-t, we were able to reproduce the issue where reactions would go away for a split second. This does not reproduce anymore in 4.61.0 after message list loading updates. Please let us know if you have any trouble with this.

laevandus avatar Jul 31 '24 12:07 laevandus