-
Notifications
You must be signed in to change notification settings - Fork 742
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
There is no need to call job.cancel() when we are using viewModelScope() #4603
There is no need to call job.cancel() when we are using viewModelScope() #4603
Conversation
@@ -233,7 +233,6 @@ class RoomDirectoryViewModel @AssistedInject constructor( | |||
} | |||
|
|||
override fun onCleared() { | |||
currentJob?.cancel() | |||
super.onCleared() |
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.
I think we can do more cleanup by removing the fun (at both places)
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.
👍 for removing the field as well
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.
the field is still useful I think
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, override fun onCleared
can be deleted. The field is used in another line
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.
ah I see this directory viewmodel is also using it to dedupe the requests
if (currentJob == null) {
// load 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.
I would say this line is more important: https://github.com/vector-im/element-android/blob/main/vector/src/main/java/im/vector/app/features/roomdirectory/RoomDirectoryViewModel.kt#L119
Fixing issue #4602