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/rx flow migration #4363

Merged
merged 14 commits into from
Nov 4, 2021
Merged

Feature/fga/rx flow migration #4363

merged 14 commits into from
Nov 4, 2021

Conversation

ganfra
Copy link
Member

@ganfra ganfra commented Oct 28, 2021

Closes #4219
Please test it carefully.
I made some profiling to track stuff being done on main thread, looking good.


val session = activeSessionHolder.getSafeActiveSession() ?: return Disposables.empty()
hasPinCode.set(pinCodeStore.getEncodedPin() != null)
val session = activeSessionHolder.getSafeActiveSession() ?: return Job()
return session.getRoomSummariesLive(
Copy link
Contributor

@ouchadam ouchadam Oct 28, 2021

Choose a reason for hiding this comment

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

could/should this use SessionFlow instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup I guess

@github-actions
Copy link

github-actions bot commented Oct 28, 2021

Unit Test Results

  62 files  ±0    62 suites  ±0   49s ⏱️ -15s
118 tests ±0  118 ✔️ ±0  0 💤 ±0  0 ±0 
350 runs  ±0  350 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit e43bfae. ± Comparison against base commit c22d3fb.

♻️ This comment has been updated with latest results.

@@ -95,7 +93,6 @@ class RoomMemberListViewModel @AssistedInject constructor(@Assisted initialState

if (room.isEncrypted()) {
room.flow().liveRoomMembers(roomMemberQueryParams)
.flowOn(Dispatchers.Main)
Copy link
Contributor

Choose a reason for hiding this comment

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

oooh nice catch!

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not really a catch, it's just that it's done by default as we launch in viewModelScope (which is Dipatchers.Main)

@ouchadam
Copy link
Contributor

there's a lot of changes here to review 😅 Most of the changes look like 1:1 replacements~

for the failing test compilation, we can now remove InstantRxRule

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.

small remark around if we should be using SessionFlow
otherwise LGTM, really awesome stuff 💯

no issues with a quick smoke test

  • joining rooms
  • sending/receiving messages
  • sign in

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.

A few remarks after a quick review.
Can you add a small migration file please?

@@ -41,7 +41,8 @@ ext.libs = [
jetbrains : [
'coroutinesCore' : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutines",
'coroutinesAndroid' : "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinCoroutines",
'coroutinesRx2' : "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:$kotlinCoroutines"
'coroutinesRx2' : "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:$kotlinCoroutines",
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

It depends if we still want to provide the matrix-android-sdk-rx wrapper?

Copy link
Member

Choose a reason for hiding this comment

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

If Element Android does not use matrix-android-sdk-rx anymore, I think we can remove it. This module is not exported along with the SDK

class RxConfig @Inject constructor(
private val vectorPreferences: VectorPreferences
) {
class RxConfig @Inject constructor() {
Copy link
Member

Choose a reason for hiding this comment

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

Shall we just remove this class?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep thanks

).asObservable()
.throttleFirst(300, TimeUnit.MILLISECONDS)
).asFlow()
.sample(300)
Copy link
Member

Choose a reason for hiding this comment

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

this is not replaced by throttleFirst here?

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks

.observeOn(Schedulers.computation())
.throttleFirst(300, TimeUnit.MILLISECONDS)
.subscribe {
.sample(300)
Copy link
Member

Choose a reason for hiding this comment

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

This is not replaced by throttleFirst here?

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks

).size
}
).asFlow()
.sample(300)
Copy link
Member

Choose a reason for hiding this comment

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

throttleFirst?

@@ -40,6 +40,7 @@ import im.vector.app.features.home.room.detail.upgrade.MigrateRoomBottomSheet
import im.vector.app.features.roomprofile.RoomProfileArgs
import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedActions
import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedEvents
import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedFragment
Copy link
Member

Choose a reason for hiding this comment

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

Strange change (just one new import in this file?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Weird, maybe from a merge?

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.
I will do another code review today to ensure everything is fine.

launchIn(viewModelScope)
```

Also be aware that when using these scopes the coroutine is launched on Dispatchers.Main by default.
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the doc! Really helpful

@@ -114,7 +114,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
this.memberships = Membership.activeMemberships()
}, sortOrder = RoomSortOrder.NONE
).asFlow()
.sample(300)
.throttleFirst(300)
Copy link
Member

@bmarty bmarty Oct 29, 2021

Choose a reason for hiding this comment

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

Since they were some small mistakes like that, I will review the PR again more carefully.

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.

Made a second deeper review. I'm not sure to get the diff betwwen sample and throttleFirst.

'glideImageViewFactory' : "com.github.piasy:GlideImageViewFactory:$bigImageViewer",
'flowBinding' : "io.github.reactivecircus.flowbinding:flowbinding-android:$flowBinding",
'flowBindingAppcompat' : "io.github.reactivecircus.flowbinding:flowbinding-appcompat:$flowBinding",
'flowBindingMaterial' : "io.github.reactivecircus.flowbinding:flowbinding-material:$flowBinding"
Copy link
Member

Choose a reason for hiding this comment

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

update the file open_source_license.html?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep I will


visibleEventsSource
.stream()
.chunk(1000)
Copy link
Member

Choose a reason for hiding this comment

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

chunk is replacing buffer?

Copy link
Member Author

@ganfra ganfra Nov 2, 2021

Choose a reason for hiding this comment

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

Yes, it's the kotlin keyword for rx "buffer"

.doOnError { err -> Timber.e(err) }
.observeOn(AndroidSchedulers.mainThread())
.subscribe { query ->
.sample(600)
Copy link
Member

Choose a reason for hiding this comment

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

Another mistake here I think.

@@ -166,12 +165,12 @@ class DevicesViewModel @AssistedInject constructor(
// )
// }

refreshPublisher.throttleFirst(4_000, TimeUnit.MILLISECONDS)
.subscribe {
refreshSource.stream().sample(4_000)
Copy link
Member

Choose a reason for hiding this comment

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

and here

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure this is really important but changed

<b>rxbinding</b>
<br/>
Copyright (C) 2015 Jake Wharton
Copyright 2019 Yang Chen
Copy link
Member

Choose a reason for hiding this comment

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

👍

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
For Element 1.3.8

@bmarty bmarty merged commit f3655d4 into develop Nov 4, 2021
@bmarty bmarty deleted the feature/fga/rx_flow_migration branch November 4, 2021 17:44
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.

Finish migration from RxJava to Flow
3 participants