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

[Threads v2] Add `ChatThreadListVC` UI Component

Open nuno-vieira opened this issue 1 year ago β€’ 2 comments

πŸ”— Issue Links

Resolves https://github.com/GetStream/ios-issues-tracking/issues/752

🎯 Goal

  • Add a new Thread List UI Component to fetch the current user threads.
  • Wires the new Threads v2 API with the UI Components.

πŸ“ Summary

  • [x] Changes the Demo App to show a Tab Bar with Channels and Threads
  • [x] Fixes marking unread inside a ChatThreadVC not doing anything.
  • [x] Adds markUnread action to root of the thread in ChatThreadVC
  • [x] Changes the default values of ThreadListQuery so that they have better performance by default
  • [x] Refactors ChatChannelUnreadCountView so that it is reusable in ChatThreadListItemView
  • [x] Renames loadOlderThreads to loadMoreTreads to be aligned with other controllers
  • [x] Exposes ChatThreadListController
  • [x] Exposes ChatThreadListRouter
  • [x] Exposes ChatMessageController.markThreadRead()
  • [x] Exposes ChatMessageController.markThreadUnread()
  • [x] Exposes ChatMessageController.updateThreadInfo()
  • [x] Exposes ChatMessageController.getThreadInfo()
  • [x] Marks a thread read when reaching the bottom of ChatThreadVC
  • [x] Exposes new ChatCurrentUserController.getUnreads()
  • [x] Update Application Badge Notifications in the Demo App
  • [x] Adds new DebugObjectViewController to Demo App
  • [x] Unit Tests
  • [x] Adds Empty and Loading states to ChatThreadListVC
  • [x] Snapshot Tests
  • [ ] Docusaurus Thread v2 Docs
  • [ ] State Layer support (Out of Scope)

πŸ›  Implementation

Currently there are a couple backend issues that are blocking this feature, the ones with πŸ”΄ are blocking:

  • :red_circle: thread.readsometimes does not contain the current user read, so it is not possible to display the number of unread replies
  • :red_circle: unread_threads is not updated when a new reply is created. I get a message.new event and notification.thread_message_new, but none of the 2 contains unread_threads, only the other unreads values.
  • The pages in the thread list some times does not contain the number provided in the limit even tho there are more pages. Ticket already created in the backend side: https://getstream.slack.com/archives/CE5N802GP/p1716911267619619?thread_ts=1716831868.119549&cid=CE5N802GP
  • When a thread is mark unread, the mark unread event does not contain any information that is about a thread, and does not include the parentMessageId of the thread
  • Not possible to correctly parse the thread.updated event or Partial Thread response due to:
    • thread.channel.commands only returns string instead of the full command structure
    • thread.thread_participants.user user object in thread participants is not returned

🎨 Showcase

πŸ§ͺ QA Scenarios

Fetch Thread List [SDK βœ… - Backend βœ… ]
  1. Tap on threads
  2. Should load current user threads
  3. When scrolling to the bottom
  4. Should load new threads βœ…

Known Issues:

  • [x] First page has few threads because most of them are missing parent_messages field.
Thread List Loading [SDK βœ… - Backend βœ…]
  1. Logout
  2. Login
  3. Tap on Threads
  4. Should show a loading spinner on the first time since no DB cache is available βœ…
Fetch Thread List Empty [SDK βœ… - Backend βœ…]
  1. Logout
  2. Login with R2-D2
  3. Tap on Threads
  4. Should show an empty view βœ…
New Thread Reply [SDK βœ… - Backend πŸ”΄ ]
  1. Login with User A (ex: Han Solo)
  2. Login with User B (ex: Luke Skywalker)
  3. Tap on Threads with User A
  4. With User B, send a reply to a thread where User A is also present
  5. User A should see the thread list updated with the new reply and unread count increased βœ…
  6. User A should see the unread threads badge increased +1 πŸ”΄

Known Issues:

  • [x] Badge appears but does not show number (UI Bug)
  • [x] Backend thread.unread is not updated, only local data. If User A logout and login, the unread count will disappear. (This happens 100% for threads that already exist)
Thread Soft Deleted [SDK βœ… - Backend βœ…]

Not Done Yet:

  1. Login with User A (ex: Han Solo)
  2. Login with User B (ex: Luke Skywalker)
  3. Tap on Threads with User A
  4. With User B, SOFT deletes a thread parent message
  5. User A should see "replied to: This message was deleted." in the Thread List βœ…
Thread Hard Deleted [SDK βœ… - Backend πŸ”΄ ]

Not Done Yet:

  1. Login with User A (ex: Han Solo)
  2. Login with User B (ex: Luke Skywalker)
  3. Tap on Threads with User A
  4. With User B, HARD deletes a thread parent message
  5. User A should see the thread disappear from the Thread List βœ…
    1. User A should see the thread unread badge decreased by one if there were unread replies πŸ”΄ (Backend)
Update Thread [SDK βœ… - Backend βœ… ]
  1. Login with User A (ex: Han Solo)
  2. Login with User B (ex: Luke Skywalker)
  3. Tap on Threads with User A
  4. Open a Thread with User B
  5. Tap on the Bug Icon top right corner with User B
  6. Update the Thread Title to something else
  7. User A should see the updated thread name in the Thread List (replied to: XXXX) βœ…
New Thread from current user [SDK βœ… - Backend βœ…]
  1. Login
  2. Open a Channel
  3. Create a new thread on that channel (Long tap on a message and thread reply)
  4. Go back to the Channel List
  5. Tap on Threads
  6. Should fetch the Thread List with the new thread βœ…
New Thread from other user mention [SDK βœ… - Backend πŸ”΄ ]
  1. Login with User A (ex: Han Solo)
  2. Login with User B (ex: Luke Skywalker)
  3. Tap on Threads with User A
  4. Create a new thread with User B (Long tap on a message without replies and tap thread reply)
  5. Send a reply by tagging User A with @
  6. User A should see a banner "X new threads" in the Thread List βœ…
  7. User A should see the new thread when tapping the banner βœ…
  8. User A should see the new thread with updated unread count πŸ”΄
Channel Deletion [SDK βœ… - Backend πŸ”΄]
  1. Login with User A (ex: Han Solo)
  2. Login with User B (ex: Luke Skywalker)
  3. Open a channel with User A
  4. Create a new thread on that channel with User A (Long tap on a message and thread reply)
  5. Go to the Thread List with User A
  6. Open the same channel with User B
  7. Open the newly created thread with User B
  8. Send a reply to that thread with User B
  9. User A should see new unreads in the Thread List βœ…
  10. User A should see thread unread badge updated βœ…
  11. User B deletes the channel
  12. User A should see the Thread disappear from Thread List βœ…
  13. User A should see the thread unread badge decreased by one if there were unread replies πŸ”΄ (Backend)
Mark Thread Unread [SDK βœ… - Backend βœ… ]
  1. Login
  2. Tap on Threads
  3. Open a read thread (without unreads)
  4. Scroll to the top to the parent message
  5. Long tap the parent message
  6. Mark it as unread
  7. Go back to the Thread List
  8. Should display unread count equal to 1 βœ…
  9. Should increase threads total unread count badge βœ…
  10. Logout
  11. Login
  12. Should still display unread count equal to 1 ❌ (Backend does not return thread.read)

Known Issues:

  • [ ] Backend updates the thread.read.unreadMessageCount to 1, instead of the number of reply count
Mark Thread Read [SDK βœ… - Backend βœ…]
  1. Login
  2. Tap on Threads
  3. Open an unread thread
  4. Scroll to the bottom of the thread
  5. Go back to the Thread List
  6. Should display no unread counts βœ…

β˜‘οΈ Contributor Checklist

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

nuno-vieira avatar May 31 '24 18:05 nuno-vieira

2 Warnings
:warning: Big PR
:warning: The changes should be manually QAed before the Pull Request will be merged

Generated by :no_entry_sign: Danger

github-actions[bot] avatar Jun 13 '24 21:06 github-actions[bot]