stream-chat-swift
stream-chat-swift copied to clipboard
Read/Unread State is not working when chat is embedded in TabBar
What did you do?
I added the Chat as documented in our app within a TabBar. I noticed that whenever the ViewController was loaded once, the unread-states did not work as expected.
What did you expect to happen?
The ChatChannelVC should not mark messages as read when a viewDidDisappear has happened.
What happened instead?
The ChatChannelVC marks all messages as read, even if the tab is not selected, thus the screen is not currently shown.
GetStream Environment
GetStream Chat version: 4.16.0 GetStream Chat frameworks: StreamChat, StreamChatUI iOS version: Swift version: Xcode version: Device:
Additional context
It would be great if that either works automatically or I can set a flag to prevent the ChatChannelVC from marking messages read.
Hi @martindaum,
thanks for the report. We will review the issue with the team and come back to you soon.
Best, Boris
Hey @martindaum,
I created a ticket for this issue internally. We will provide a way to not mark the messages as read automatically. We will update this ticket once the functionality is released.
Thanks for understanding.
Best, Boris
Any news on this? This is still a blocker for us to release our version including the Stream-SDK.
Hi @martindaum,
We have this planned to work on the next week.
Either way, I was looking at the issue right now, and something seems to be wrong from the integration point of view. What do you mean by "The ChatChannelVC should not mark messages as read when a viewDidDisappear has happened." ? We do not mark channels read on viewDidDisappear. We only mark them when the View Controller appears on the screen. So only when you select on the TabBar, it should mark them as unread. I just tested this with our DemoApp, and it works. Only when I select the tabBar where is the channel view, the viewDidAppear is called, and we mark the channel read. Is it possible for you to show a snippet on how you are building your tab bar?
Best, Nuno
Hi @martindaum,
Have you read my message above? It seems we can't really do much on our side to fix this issue, since it is App logic. We could verify if the tab bar is currently selected, but this has the same effect as viewDidAppear. My guess is that something on your app is triggering the viewDidAppear.
Thank you, Nuno
Hi! I can test again if something has changed in the implementation. Last time I checked, it did not matter if the tab was selected or not, all messages were marked as read immediately as long as the chat was contained in a tab. I have debugged the issue in your code, it did always enter the method were it checked if the scrollview was scrolled to the last message and then marked everything as read. But the chat was not visible because it was not selected in the tabbar.
@martindaum from my testing, the scrollViewDidScoll event is only called when the tab bar is selected as well.
Either way, you can easily fix this on your side. You can override scrollViewDidScroll and only call super.scrollViewDidScroll if the tab bar is selected.
Still, the event is getting called for me even if it is not selected. But your workaround overriding scrollViewDidScroll does the trick! Thanks!
No problem! That should be enough for now :)