GetStream / stream-chat-swiftui

SwiftUI Chat SDK โžœ Stream Chat ๐Ÿ’ฌ
https://getstream.io/chat/sdk/swiftui/
Other
342 stars 84 forks source link

Channel was sometimes marked as read on open #593

Closed laevandus closed 1 month ago

laevandus commented 1 month ago

๐Ÿ”— Issue Link

Resolves: PBE-5810

๐ŸŽฏ Goal

Fix the issue or marking a channel as read when the first unread message was one of the first not visible messages

๐Ÿ›  Implementation

The fix is a workaround to the SwiftUI issue where the LazyVStack pushed to the NavigationStack has initially larger height and therefore trigger onAppear for more messages than it should. This causes ChatChannelViewModel to mark the channel as read because it thinks the user also saw the first unread message. Apple's feedback id is: FB15010770.

๐Ÿงช Testing

  1. Open a channel
  2. Scroll to the second message which was not visible on channel open
  3. Use mark unread using that message
  4. Go to channel list and open the same channel again

Before: Unread message pill appeared for a split second and the channel was marked as read Expected: Unread message pill appears at the top of the channel view.

๐ŸŽจ Changes

Note how in the before video the second opening on the channel marked it as read (the pill went away).

Before After
Before After

โ˜‘๏ธ Checklist

Stream-SDK-Bot commented 1 month ago

SDK Size

title develop branch diff status
StreamChatSwiftUI 7.06 MB 7.06 MB +2 KB ๐ŸŸข
sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
88 New issues
0 Accepted issues

Measures
0 Security Hotspots
72.2% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud