-
Notifications
You must be signed in to change notification settings - Fork 731
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
Conversation
|
||
val session = activeSessionHolder.getSafeActiveSession() ?: return Disposables.empty() | ||
hasPinCode.set(pinCodeStore.getEncodedPin() != null) | ||
val session = activeSessionHolder.getSafeActiveSession() ?: return Job() | ||
return session.getRoomSummariesLive( |
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.
could/should this use SessionFlow
instead?
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.
Yup I guess
@@ -95,7 +93,6 @@ class RoomMemberListViewModel @AssistedInject constructor(@Assisted initialState | |||
|
|||
if (room.isEncrypted()) { | |||
room.flow().liveRoomMembers(roomMemberQueryParams) | |||
.flowOn(Dispatchers.Main) |
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.
oooh nice catch!
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.
It's not really a catch, it's just that it's done by default as we launch in viewModelScope (which is Dipatchers.Main)
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 |
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.
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
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.
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", |
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 still need this?
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.
It depends if we still want to provide the matrix-android-sdk-rx wrapper?
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.
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() { |
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.
Shall we just remove this class?
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.
Yep thanks
).asObservable() | ||
.throttleFirst(300, TimeUnit.MILLISECONDS) | ||
).asFlow() | ||
.sample(300) |
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 is not replaced by throttleFirst
here?
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
.observeOn(Schedulers.computation()) | ||
.throttleFirst(300, TimeUnit.MILLISECONDS) | ||
.subscribe { | ||
.sample(300) |
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 is not replaced by throttleFirst
here?
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
).size | ||
} | ||
).asFlow() | ||
.sample(300) |
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.
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 |
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.
Strange change (just one new import in this file?)
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.
Weird, maybe from a merge?
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 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. |
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 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) |
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.
Since they were some small mistakes like that, I will review the PR again more carefully.
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.
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" |
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.
update the file open_source_license.html?
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.
Yep I will
|
||
visibleEventsSource | ||
.stream() | ||
.chunk(1000) |
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.
chunk
is replacing buffer
?
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, it's the kotlin keyword for rx "buffer"
.doOnError { err -> Timber.e(err) } | ||
.observeOn(AndroidSchedulers.mainThread()) | ||
.subscribe { query -> | ||
.sample(600) |
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.
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) |
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.
and here
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.
Not sure this is really important but changed
<b>rxbinding</b> | ||
<br/> | ||
Copyright (C) 2015 Jake Wharton | ||
Copyright 2019 Yang Chen |
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.
👍
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 update
For Element 1.3.8
Closes #4219
Please test it carefully.
I made some profiling to track stuff being done on main thread, looking good.