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

[ChatStateLayer] Reset contexts when logging out

Open laevandus opened this issue 2 months ago • 2 comments

🔗 Issue Links

Related: #728

Merges to feature/chat-state-layer

🎯 Goal

Fix logout issue with duplicate channels in DB.

📝 Summary

While testing the new state in the SwiftUI SDK we found an issue:

  1. Log in with A
  2. Open channel with A and B
  3. Logout and log in with B
  4. Open channel with A and B → issue happens (assert telling multiple ChannelDTOs for the same cid)

Simulator Screen Recording - iPhone 15 Pro - 2024-04-24 at 15 44 39

🛠 Implementation

It seems like when we flush the database on logout, open channel is not flushed. Not sure, but I think it is related to state layer's context which immediately reacts to changes.

☑️ Contributor Checklist

  • [x] I have signed the Stream CLA (required)
  • [x] This change follows zero ⚠️ policy (required)
  • [ ] This change should be manually QAed
  • [ ] Changelog is updated with client-facing changes
  • [ ] New code is covered by unit tests
  • [ ] Comparison screenshots added for visual changes
  • [ ] Affected documentation updated (docusaurus, tutorial, CMS)

laevandus avatar Apr 24 '24 12:04 laevandus

1 Message
:book: There seems to be app changes but CHANGELOG wasn't modified.
Please include an entry if the PR includes user-facing changes.
You can find it at CHANGELOG.md.

Generated by :no_entry_sign: Danger

github-actions[bot] avatar Apr 24 '24 13:04 github-actions[bot]

StreamChat XCMetrics

target metric benchmark branch performance status
MessageList Hitches total duration 10 ms 15.02 ms -50.2% 🔽 🔴
Duration 2.6 s 2.54 s 2.31% 🔼 🟢
Hitch time ratio 4 ms per s 5.92 ms per s -48.0% 🔽 🔴
Frame rate 79 fps 78.24 fps 0.96% 🔼 🟢
Number of hitches 1 1.2 -20.0% 🔽 🔴
ChannelList Hitches total duration 12.5 ms 0.0 ms 100.0% 🔼 🟢
Duration 2.6 s 0.83 s 68.08% 🔼 🟢
Hitch time ratio 5 ms per s 0.0 ms per s 100.0% 🔼 🟢
Frame rate 76 fps 63.57 fps 16.36% 🔼 🟢
Number of hitches 1.2 0.0 100.0% 🔼 🟢

Stream-iOS-Bot avatar Apr 24 '24 13:04 Stream-iOS-Bot

I am going to move this PR to develop. Closing!

laevandus avatar Apr 29 '24 06:04 laevandus