-
Notifications
You must be signed in to change notification settings - Fork 5
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
When expanding a long Thread, display Messages by batches so it doesn't freeze the UI anymore #2044
base: master
Are you sure you want to change the base?
Conversation
4cf2c97
to
cc4cc09
Compare
cc4cc09
to
5ff3762
Compare
@@ -73,6 +73,7 @@ class ThreadViewModel @Inject constructor( | |||
|
|||
val threadLive = MutableLiveData<Thread?>() | |||
val messagesLive = MutableLiveData<Pair<ThreadAdapterItems, MessagesWithoutHeavyData>>() | |||
val batchedMessages = SingleLiveEvent<List<Any>>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having to rely in SingleLiveEvent can't we have a live data that represents the list of all loaded messages? This way we can listen in a straight forward manner to the list of messages, when the list updates, we submit the new list. The logic to delay the loading can then be handle on its own independently and the logic is not split depending on if we have more or less messages than ThreadViewModel.SUPER_COLLAPSED_BLOCK_MINIMUM_MESSAGES_LIMIT
if (items.count() > ThreadViewModel.SUPER_COLLAPSED_BLOCK_MINIMUM_MESSAGES_LIMIT) { | ||
displayBatchedMessages(items) | ||
} else { | ||
threadAdapter.submitList(items) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can displayBatchedMessages()
handle both cases inside by having the method automatically do less than SUPER_COLLAPSED_BLOCK_MINIMUM_MESSAGES_LIMIT
if there's not enough items left?
5ff3762
to
e0dc712
Compare
Quality Gate passedIssues Measures |
Why do we do all of this again though? |
In the situation of a Thread long enough so we display the SuperCollapsedBlock :