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

Feature/fga/timeline chunks rework #4405

Merged
merged 39 commits into from
Jan 3, 2022
Merged

Conversation

ganfra
Copy link
Member

@ganfra ganfra commented Nov 3, 2021

This PR is a first step in the refactoring of the timeline.
It should also fix #4280 (not reproduced)

The main changes are:

  • Previous live chunk are now deleted when we have a gap.
  • We create small chunks and link them with previous/next instead of merging
  • Each chunk listen only for his events
  • Creation of smaller classes.

This is still not ideal, but it will be easier to evolve from there after hopefully.

@ganfra ganfra marked this pull request as draft November 3, 2021 18:16
@github-actions
Copy link

github-actions bot commented Nov 3, 2021

Unit Test Results

  66 files  ±0    66 suites  ±0   59s ⏱️ +7s
135 tests ±0  135 ✔️ ±0  0 💤 ±0  0 ±0 
418 runs  ±0  418 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 9121585. ± Comparison against base commit ff2e7d8.

♻️ This comment has been updated with latest results.

@ganfra ganfra marked this pull request as ready for review December 9, 2021 13:21
@ouchadam ouchadam self-requested a review December 14, 2021 09:08
}
}
}

/*
private fun cleanUp(realm: Realm, threshold: Long) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this cleanup not needed anymore? if so we could probably delete the class as it's only logging the number of rooms (or make it debug~ only)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted!

private val mode: Mode,
private val dependencies: Dependencies) {

sealed class Mode {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this could be a sealed interface

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

fun buildSendingEvents(): List<TimelineEvent>
}

internal class RealmSendingEventsDataSource(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 for extracting this to its own smaller class

LoadMoreResult.FAILURE
}
return if (loadMoreResult == LoadMoreResult.SUCCESS) {
latch?.await()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be safer to use await with a timeout or does this logic cancel when exiting the timeline?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scope is closed so this should cancel when exiting

Copy link
Contributor

@ouchadam ouchadam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 no blockers from my side although I'm very new to this area and don't know a lot of the history/context

didn't notice any issues with a local smoke test

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work!
Thanks @ouchadam for the smoke test, happy to merge this PR fast to develop once the changelog files are added.

/**
* Called when the pagination state has changed in one direction
*/
fun onStateUpdated(direction: Direction, state: PaginationState) = Unit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you advertise the API break using a changelog file 4405.removal please? Another 4405.feature can simply tell that the timeline management has been reworked.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removal?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because according to https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#changelog:

.removal: Signifying a deprecation or removal of public API. Can be used to notifying about API change in the Matrix SDK

and https://github.com/vector-im/element-android/blob/develop/towncrier.toml#L25

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -28,3 +28,13 @@ internal fun TimelineEventEntity.Companion.nextId(realm: Realm): Long {
currentIdNum.toLong() + 1
}
}

internal fun TimelineEventEntity.isMoreRecentThan(eventToCheck: TimelineEventEntity): Boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename eventToCheck to other

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

var stateEvents: RealmList<EventEntity> = RealmList(),
var timelineEvents: RealmList<TimelineEventEntity> = RealmList(),
var numberOfTimelineEvents: Long = 0,
// var numberOfTimelineEvents: Long = 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just delete the commented out code? Or will it be uncommented in the future?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will delete, thanks

@@ -46,7 +46,5 @@ internal fun TimelineEventEntity.deleteOnCascade(canDeleteRoot: Boolean) {
if (canDeleteRoot) {
root?.deleteFromRealm()
}
annotations?.deleteOnCascade()
readReceipts?.deleteOnCascade()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed anymore? Can you explain?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annotations and read receipts persistence is supposed to be independent
from timeline. This is what caused reactions to be lost during gap

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the table for annotations will grow up indefinitely, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes until cache is cleared

TimelineInput.Listener,
UIEchoManager.Listener {

internal class DefaultTimeline internal constructor(private val roomId: String,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove internal constructor

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* ========================================================================================================
* </pre>
*/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RIP

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update!

@bmarty bmarty merged commit d670d3e into develop Jan 3, 2022
@bmarty bmarty deleted the feature/fga/timeline_chunks_rework branch January 3, 2022 19:20
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.

Reactions are lost on old events
3 participants