Skip to content

Fix loading initial items of non-live timelines#6598

Merged
jmartinesp merged 4 commits intodevelopfrom
fix/timelines-not-loading-initial-items-if-they-are-not-cached
Apr 16, 2026
Merged

Fix loading initial items of non-live timelines#6598
jmartinesp merged 4 commits intodevelopfrom
fix/timelines-not-loading-initial-items-if-they-are-not-cached

Conversation

@jmartinesp
Copy link
Copy Markdown
Member

Content

Items in non-live timelines aren't loaded automatically anymore if they're not present in the cache. This is specially easy to spot when loading a thread timeline.

This was done automatically by the SDK in the past by returning a Reset timeline update, but this behaviour changed and now we have to do it.

Motivation and context

Fix the initial loading of timeline items when they're not cached after matrix-org/matrix-rust-sdk#6380.

Tests

Either clear the cache or make sure you're opening a thread you haven't loaded yet. Open the thread screen, if timelines appear, this should be fixed.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 13

Checklist

  • This PR was made with the help of AI:
    • Yes. In this case, please request a review by Copilot.
    • No.
  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly defines what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

@jmartinesp jmartinesp requested a review from a team as a code owner April 16, 2026 09:31
@jmartinesp jmartinesp added the PR-Bugfix For bug fix label Apr 16, 2026
@jmartinesp jmartinesp requested review from bmarty and removed request for a team April 16, 2026 09:31
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/zGsKXy

@jmartinesp jmartinesp force-pushed the fix/timelines-not-loading-initial-items-if-they-are-not-cached branch from f10d82f to b1c07d9 Compare April 16, 2026 09:48
@jmartinesp jmartinesp added the Z-NextRelease For issues and PRs which should be included in the NextRelease. label Apr 16, 2026
Copy link
Copy Markdown
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, I confirm that it fixes the issue of empty thread timeline on my side


// If we are not in live timeline mode, and we have no timeline items, we need to back paginate to load some messages.
// This was previously done by the SDK, and we received a `Reset` update, but now we need to do it ourselves.
val isEmptyNonLiveTimelineFlow = layoutInfoFlow.map { it.totalItemsCount == 0 && timelineMode != Timeline.Mode.Live }
Copy link
Copy Markdown
Member

@bmarty bmarty Apr 16, 2026

Choose a reason for hiding this comment

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

Is the test on timelineMode necessary here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It may not bee needed. Since live timelines are supposed to always have at least 1 item, the it.totalItemsCount == 0 check wouldn't be used and we wouldn't unnecessarily paginate.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It worked fine when I tested this without the mode check: f43317b

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.14%. Comparing base (d8c5409) to head (384f35e).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
...id/features/messages/impl/timeline/TimelineView.kt 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #6598   +/-   ##
========================================
  Coverage    81.14%   81.14%           
========================================
  Files         2623     2623           
  Lines        72804    72806    +2     
  Branches      9418     9418           
========================================
+ Hits         59078    59080    +2     
  Misses       10254    10254           
  Partials      3472     3472           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This was done automatically by the SDK in the past by returning a `Reset` timeline update, but this behaviour changed and now we have to do it.
@jmartinesp jmartinesp force-pushed the fix/timelines-not-loading-initial-items-if-they-are-not-cached branch from b1c07d9 to f43317b Compare April 16, 2026 10:33
@jmartinesp jmartinesp enabled auto-merge (squash) April 16, 2026 10:38
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
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!

@jmartinesp jmartinesp merged commit c349f74 into develop Apr 16, 2026
31 of 32 checks passed
@jmartinesp jmartinesp deleted the fix/timelines-not-loading-initial-items-if-they-are-not-cached branch April 16, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Bugfix For bug fix Z-NextRelease For issues and PRs which should be included in the NextRelease.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants