stream-chat-android
stream-chat-android copied to clipboard
[ISSUE-3710] Thread query listener impl separation
🎯 Goal
Prepare ThreadQueryListenerImpl to handle both state and/or persistence accordingly with how users configure the SDK.
🛠 Implementation details
-
ThreadLogicis no longer the implementation ofThreadQueryListener. There's already a specific class for that which isThreadQueryListenerImpl(orThreadQueryListenerFull) now.ThreadLogicshould only handle the logic of threads instead of also being a lister of ChatClient requests. This way each class becomes more specialized. -
ThreadQueryListenerFullhandles both state and persistence, but its properties are optional.
I don't believe this class should be separated into database and state completely because the code uses persistence to update the state if the information lives only inside the database at the moment the listener is called. Separating it would cause more requests to API, because the state won't be aware that information can be fetched from persistence.
As a solution, the properties that handle each case are now optional and the class adapts itself to the configuration of the SDK. If no persistence is provided by the user, this class only interacts with the state and updates it with the data that comes from the API. If only the database is provided, the state is not propagated and only the database receives updates. If none of the dependencies is provided, this class doesn't do anything and becomes a NOOP listener.
🧪 Testing
Check the threads inside the channels.
☑️Contributor Checklist
General
- [x] I have signed the Stream CLA (required)
- [x] Assigned a person / code owner group (required)
- [x] Thread with the PR link started in a respective Slack channel (#android-chat-core or #android-chat-ui) (required)
- [x] PR targets the
developbranch - [x] PR is linked to the GitHub issue it resolves
Code & documentation
- ~[ ] Changelog is updated with client-facing changes~. There's no client facing changes
- [ ] New code is covered by unit tests. Let's discuss the approach first.
- ~[ ] Comparison screenshots added for visual changes~
- [x] 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
I didn't find a good giphy for this pr...