-
Notifications
You must be signed in to change notification settings - Fork 739
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
Convert StateService to suspend functions #2500
Convert StateService to suspend functions #2500
Conversation
Signed-off-by: aqulu <[email protected]>
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 your PR.
I got just one question, and I will be more comfortable if @ganfra can have a look on the change regarding the Widget part.
Also the CI is not happy, could you fix that please?
Thanks!
.executeBy(taskExecutor) | ||
body: JsonDict | ||
) { | ||
withContext(coroutineDispatchers.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.
Why changing the context 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.
Sorry, didn't read executeBy(taskExecutor)
internals properly.
TaskExecutor.execute ran this on the callback's thread (by transforming it with toDispatcher()
internally). I'll remove the context change.
override fun updateJoinRule(joinRules: RoomJoinRules?, guestAccess: GuestAccess?, callback: MatrixCallback<Unit>): Cancelable { | ||
return taskExecutor.executorScope.launchToCallback(coroutineDispatchers.main, callback) { | ||
override suspend fun updateJoinRule(joinRules: RoomJoinRules?, guestAccess: GuestAccess?) { | ||
withContext(coroutineDispatchers.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.
same question 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.
This was launched this in the coroutineDispatchers.main
context by taskExecutor.executorScope.launchToCallback(coroutineDispatchers.main, callback)
before.
I'm happy to remove the explicit withContext
though.
override fun updateAvatar(avatarUri: Uri, fileName: String, callback: MatrixCallback<Unit>): Cancelable { | ||
return taskExecutor.executorScope.launchToCallback(coroutineDispatchers.main, callback) { | ||
override suspend fun updateAvatar(avatarUri: Uri, fileName: String) { | ||
withContext(coroutineDispatchers.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.
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.
Thanks for the review!
I'll fix the CI errors and get rid of the context-changes you pointed out. |
Signed-off-by: aqulu <[email protected]>
Signed-off-by: aqulu <[email protected]>
Signed-off-by: aqulu <[email protected]>
Signed-off-by: aqulu <[email protected]>
CI should be fixed now. Looks like buildkite's "Compile and run Unit tests" job hung up - executing the command on my local machine completes successfully. |
stateKey = null, | ||
body = params | ||
) | ||
widgetPostAPIMediator.sendSuccess(eventData) |
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.
Should this be done inside the try
block? If it throws, sendError
will also be called, which isn't strictly the previous behaviour.
(Same for below)
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 pointing this out! Fixed in ed822be
I've been quite busy lately and haven't been able to contribute to this, but I wasn't expecting anybody else to do these. Also, feel free to tag me to review these. |
Signed-off-by: aqulu <[email protected]>
@Dominaezzz Sorry for interfering with these, that wasn't my intention 🙇 |
Oh no! 😨 Don't stop on my behalf! It would be amazing to have these done sooner than later aha. Looking forward to your next PR! 🎉 😀 |
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.
LGTM now, thanks for the update!
It seems that we have touch the StateService. Would you mind to rebase your change on develop, or merge develop to your branch?
Actually I think I can do it with Github UI |
Signed-off-by: aqulu [email protected]
Pull Request Checklist
Summary
kotlinx-coroutines-rx2
rxCompletableGlobalScope
. The job will be cancelled when the resulting Completable is, which is similar tocompletableBuilder
's behavior in matrix-sdk-android-rxGlobalScope.launch
to run suspendable functionsCoroutineScope
instance does not solve the issue, as running jobs would not be cancelled by lifecycle events.WidgetViewModel
so it could potentially be tied to it's lifecycle to avoid using GlobalScope.TaskExecutor
's coroutine scope. All jobs in this scope will be cancelled when CacheService.clearCache is invoked. As far as i understand this is a side-effect of cache clearing rather than it's primary goal.