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

[AND-25] Threads V2 offline support #5481

Merged
merged 88 commits into from
Nov 20, 2024
Merged

Conversation

VelikovPetar
Copy link
Contributor

🎯 Goal

The PR includes 2 significant changes:

  • Fixes the handling of the NotificationMarkUnread event, which now correctly delivers a threadId, if the event is delivered when marking a thread
  • Introduces offline support for the thread list

🛠 Implementation details

  1. Introduce ThreadEntity - DB model for the domain Thread model.
  2. Introduce ThreadOrderEntity - DB model which persists the order of the threads as initially delivered from BE (we don't know the exact sorting the BE does, so this is a way of persisting the same order)
  3. Introduce ThreadDao and ThreadOrderDao for DB interaction
  4. Introduce ThreadRepository with two implementations: DatabaseThreadRepository and the fallback NoOpThreadRepository
  5. Introduce QueryThreadsListenerDatabase which inserts thread data into the DB after every successful HTTP queryThreads() call.
  6. Enhance QueryThreadsLogic to pre-populate the QueryThreadsState with previously fetched offline data
  7. Update threads DB data on relevant web socket events: NewMessageEvent, DeleteMessageEvent, UpdateMessageEvent, ReactionNewEvent, ReactionUpdatedEvent, ReactionDeletedEvent, MessageReadEvent, NotificationMarkUnreadEvent
  8. Update RepositoryFacade to ensure thread data is updated when calling insertMessage, insertMessages or deleteChannel
  9. Extract some common Thread update methods such as updateParent/upsertReply/... to client.extensions.internal.Thread file

🧪 Testing

  1. Install compose sample app
  2. Open Threads tab
  3. Close app
  4. Turn connectivity off
  5. Open Threads tab
  6. Open/Edit/Add/Delete messages by opening the thread

☑️Contributor Checklist

General

  • I have signed the Stream CLA (required)
  • Assigned a person / code owner group (required)
  • Thread with the PR link started in a respective Slack channel (#android-chat-core or #android-chat-ui) (required)
  • PR targets the develop branch
  • PR is linked to the GitHub issue it resolves

Code & documentation

  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Comparison screenshots added for visual changes
  • Affected documentation updated (KDocs, docusaurus, tutorial)

☑️Reviewer Checklist

  • UI Components sample runs & works
  • Compose sample runs & works
  • UI Changes correct (before & after images)
  • Bugs validated (bugfixes)
  • New feature tested and works
  • Release notes and docs clearly describe changes
  • All code we touched has new or updated KDocs

🎉 GIF

Please provide a suitable gif that describes your work on this pull request

PetarVelikov added 30 commits October 9, 2024 09:32
# Conflicts:
#	stream-chat-android-compose/src/main/res/values/strings.xml
PetarVelikov added 22 commits October 30, 2024 14:04
# Conflicts:
#	stream-chat-android-compose/api/stream-chat-android-compose.api
# Conflicts:
#	CHANGELOG.md
#	docusaurus/sidebars-android.js
#	stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/mapping/ThreadMapping.kt
#	stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api2/model/dto/ThreadDtos.kt
#	stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/threads/ThreadItem.kt
#	stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/threads/ThreadList.kt
#	stream-chat-android-core/api/stream-chat-android-core.api
#	stream-chat-android-core/src/main/java/io/getstream/chat/android/models/ThreadInfo.kt
#	stream-chat-android-core/src/main/java/io/getstream/chat/android/models/ThreadParticipant.kt
#	stream-chat-android-state/src/main/java/io/getstream/chat/android/state/plugin/logic/internal/LogicRegistry.kt
#	stream-chat-android-state/src/main/java/io/getstream/chat/android/state/plugin/logic/querythreads/internal/QueryThreadsLogic.kt
#	stream-chat-android-state/src/main/java/io/getstream/chat/android/state/plugin/logic/querythreads/internal/QueryThreadsStateLogic.kt
#	stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/logic/querythreads/internal/QueryThreadsLogicTest.kt
#	stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/logic/querythreads/internal/QueryThreadsStateLogicTest.kt
#	stream-chat-android-state/src/test/java/io/getstream/chat/android/state/plugin/state/querythreads/internal/QueryThreadsMutableStateTest.kt
Copy link
Contributor

DB Entities have been updated. Do we need to upgrade DB Version?
Modified Entities :

stream-chat-android-offline/src/main/java/io/getstream/chat/android/offline/repository/domain/threads/internal/ThreadEntity.kt
stream-chat-android-offline/src/main/java/io/getstream/chat/android/offline/repository/domain/threads/internal/ThreadOrderEntity.kt

@VelikovPetar VelikovPetar marked this pull request as ready for review November 20, 2024 11:33
@VelikovPetar VelikovPetar requested a review from a team as a code owner November 20, 2024 11:33
@JcMinarro JcMinarro merged commit f06acf7 into develop Nov 20, 2024
9 checks passed
@JcMinarro JcMinarro deleted the feature/threads_offline branch November 20, 2024 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants