Skip to content

Remember flows #4533

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

Merged
merged 11 commits into from
Apr 4, 2025
Merged

Remember flows #4533

merged 11 commits into from
Apr 4, 2025

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Apr 4, 2025

Content

Ensure that Flows are not created again when a recomposition occurred. They should be remembered, except if they are hold in a val. So this PR:

  • add a Konsist test to detect potential issue with this
  • add remember around flow function creator
  • change fun which return flow to val, so that it's clear the the flow is not created at each usage.

Motivation and context

Tiny performance improvement and Compose best practice.

Screenshots / GIFs

No expected change

Tests

  • No expected change

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • 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 define 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

@bmarty bmarty added the PR-Misc For other changes label Apr 4, 2025
Copy link
Contributor

github-actions bot commented Apr 4, 2025

📱 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/1hjLzj

@bmarty bmarty marked this pull request as ready for review April 4, 2025 12:43
@bmarty bmarty requested a review from a team as a code owner April 4, 2025 12:43
@bmarty bmarty requested review from jmartinesp and removed request for a team April 4, 2025 12:43
Copy link

sonarqubecloud bot commented Apr 4, 2025

Copy link

codecov bot commented Apr 4, 2025

Codecov Report

Attention: Patch coverage is 95.03546% with 7 lines in your changes missing coverage. Please review.

Project coverage is 80.16%. Comparing base (c09ff58) to head (ae0ee55).
Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
.../biometric/DefaultBiometricAuthenticatorManager.kt 0.00% 3 Missing ⚠️
...roid/libraries/matrix/impl/sync/RustSyncService.kt 0.00% 1 Missing ⚠️
...oid/libraries/matrix/impl/timeline/RustTimeline.kt 83.33% 1 Missing ⚠️
...x/impl/widget/DefaultCallWidgetSettingsProvider.kt 0.00% 1 Missing ⚠️
...roid/libraries/matrix/test/sync/FakeSyncService.kt 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4533      +/-   ##
===========================================
+ Coverage    80.14%   80.16%   +0.01%     
===========================================
  Files         2083     2082       -1     
  Lines        54902    54931      +29     
  Branches      6848     6847       -1     
===========================================
+ Hits         43999    44033      +34     
+ Misses        8543     8539       -4     
+ Partials      2360     2359       -1     

☔ 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.

Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Comment on lines 27 to 32
"syncService.isOnline()",
"userListDataStore.selectedUsers()",
"accountProviderDataSource.flow()",
"syncService.isOnline()",
"timeline.paginationStatus",
"analyticsService.getUserConsent()",
Copy link
Member

Choose a reason for hiding this comment

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

Maybe using an annotation to suppress the warning would be better, but I don't know if that's possible/easy. Just something we could keep in mind for future usages of Konsist.

@@ -73,4 +74,6 @@ class RustSyncService(
}
.distinctUntilChanged()
.stateIn(sessionCoroutineScope, SharingStarted.Eagerly, SyncState.Idle)

override val isOnline: StateFlow<Boolean> = syncState.mapState { it != SyncState.Offline }
Copy link
Member

Choose a reason for hiding this comment

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

TIL about our mapState helper function 👀 .

@bmarty bmarty merged commit a230b83 into develop Apr 4, 2025
34 checks passed
@bmarty bmarty deleted the feature/bma/rememberFlows branch April 4, 2025 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Misc For other changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants