-
Notifications
You must be signed in to change notification settings - Fork 752
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
Feature/aris/thread aware #4396
Conversation
…y old messages that the root thread message is not fetched in the device and initial sync
Add documentation comments
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.
I have some remarks. I think it would be valuable if @ganfra review this PR too.
I'm wondering why it's mandatory to retrieve the root event during the sync response processing. Can we do it only if the timeline is rendered?
@@ -56,10 +57,10 @@ internal open class EventEntity(@Index var eventId: String = "", | |||
|
|||
companion object | |||
|
|||
fun setDecryptionResult(result: MXEventDecryptionResult) { | |||
fun setDecryptionResult(result: MXEventDecryptionResult, clearEvent: JsonDict? = null) { |
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.
This change is strange, let me see the rest of the changes to understand why it is done
* This function is responsible to fetch and store the root event of a thread event | ||
* in order to be able to display the event to the user appropriately | ||
*/ | ||
private fun fetchRootThreadEventsIfNeeded(offsetResults: RealmResults<TimelineEventEntity>) = runBlocking { |
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.
We should not use runBlocking
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.
Correct, but we are already in a thread (and the UI will not freeze) and it's the only way to ensure that the next code block will have the required info, if you can suggest an alternative to that it's welcome. Furthermore keep in mind that this is a temporary fix and will be removed after the thread release
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.
Yes thats not really great but it's ok I guess for now. Note that my rework of the timeline authorise direct usage of suspend methods
...droid/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt
Outdated
Show resolved
Hide resolved
...rc/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineEventDecryptor.kt
Show resolved
Hide resolved
...in/java/org/matrix/android/sdk/internal/session/sync/handler/room/ThreadsAwarenessHandler.kt
Outdated
Show resolved
Hide resolved
@@ -94,6 +96,10 @@ internal class SyncResponseHandler @Inject constructor( | |||
Timber.v("Finish handling toDevice in $it ms") | |||
} | |||
val aggregator = SyncResponsePostTreatmentAggregator() | |||
|
|||
// Prerequisite for thread events handling in RoomSyncHandler | |||
threadsAwarenessHandler.fetchRootThreadEventsIfNeeded(syncResponse) |
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.
Do we want to do that even for the initial sync? It can take time if there are lots of events to retrieve
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.
Yes, without this it will not be rendered appropriately. I think there will be never more than max 1/2 fetches per room worst case. Ofc this will be removed upon the first thread release.
Later in the handler you would need that info, especially for the 10 latest messages.
The majority of the fetching will be done when the timeline is rendered and decrypted. Furthermore, if we go with a different approach we should add loaders on messages and the complexity of that is not worth it while its just a temporarily solution, and we should not spent that much time |
if (eventList.isNullOrEmpty()) return | ||
|
||
val threadsToFetch = emptyMap<String, String>().toMutableMap() | ||
monarchy.awaitTransaction { realm -> |
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.
Why are u using awaitTransaction here?
private val permalinkFactory: PermalinkFactory, | ||
private val cryptoService: CryptoService, | ||
@SessionDatabase private val monarchy: Monarchy, | ||
private val session: Session |
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.
We shouldn't use session in the SDK this is only intended to be used by SDK user
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.
Updated accordingly
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.
Some remarks
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.
LGTM, @ganfra ?
...in/java/org/matrix/android/sdk/internal/session/sync/handler/room/ThreadsAwarenessHandler.kt
Show resolved
Hide resolved
return runCatching { | ||
Timber.i("------> Fetching event[$eventId]....") | ||
getEventTask.execute(GetEventTask.Params(roomId = roomId, eventId = eventId)).apply { | ||
unsignedData?.age?.let { System.currentTimeMillis() - it } |
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.
Maybe this should be added to the task?
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.
Thanks for the changes, ok for me now
Make Element Android Thread aware
This feature temporarily until the main threads release and will be deleted. The idea is to make smoother the thread transition release for the clients
Closes #4246
What was the main challenge?
Too old root thread messages, are not fetched in the device so is impossible to show the thread as a reply appropriately. So a custom fetch root thread event mechanism was implemented in order to fetch those root thread events prior the transformation to replies