Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Message flickering #2857

Open
borut-t opened this issue Oct 25, 2023 · 4 comments
Open

Update Message flickering #2857

borut-t opened this issue Oct 25, 2023 · 4 comments
Labels
🐞 Bug An issue or PR related to a bug 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK

Comments

@borut-t
Copy link

borut-t commented Oct 25, 2023

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

Screen.Recording.2023-10-25.at.08.37.05.mov
@martinmitrevski
Copy link
Contributor

Hey @borut-t,

Thanks for reporting, we will look into it.

@martinmitrevski
Copy link
Contributor

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?

@borut-t
Copy link
Author

borut-t commented Oct 27, 2023

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.

@martinmitrevski martinmitrevski transferred this issue from GetStream/stream-chat-swiftui Oct 30, 2023
@martinmitrevski
Copy link
Contributor

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

@nuno-vieira nuno-vieira added 🐞 Bug An issue or PR related to a bug 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK labels Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Bug An issue or PR related to a bug 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK
Projects
None yet
Development

No branches or pull requests

3 participants