mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-1357 App | Fix | Making sure to cancel subscriptions for the expanded bundled widgets and the library (#23)
This commit is contained in:
parent
177eed7178
commit
649fdb3c1f
2 changed files with 8 additions and 3 deletions
|
@ -23,6 +23,8 @@ import com.anytypeio.anytype.presentation.library.delegates.MyRelationsDelegate
|
|||
import com.anytypeio.anytype.presentation.library.delegates.MyTypesDelegate
|
||||
import com.anytypeio.anytype.presentation.navigation.NavigationViewModel
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
@ -357,13 +359,13 @@ class LibraryViewModel(
|
|||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
viewModelScope.launch {
|
||||
GlobalScope.launch {
|
||||
myRelationsDelegate.unsubscribe()
|
||||
libraryRelationsDelegate.unsubscribe()
|
||||
myTypesDelegate.unsubscribe()
|
||||
libraryTypesDelegate.unsubscribe()
|
||||
}
|
||||
super.onCleared()
|
||||
}
|
||||
|
||||
class Factory @Inject constructor(
|
||||
|
|
|
@ -68,6 +68,7 @@ import kotlinx.coroutines.flow.onEach
|
|||
import kotlinx.coroutines.flow.scan
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import timber.log.Timber
|
||||
import com.anytypeio.anytype.core_models.ObjectView as CoreObjectView
|
||||
|
||||
|
@ -176,7 +177,9 @@ class CollectionViewModel(
|
|||
|
||||
fun onStop() {
|
||||
launch {
|
||||
container.unsubscribe(listOf(subscription.id))
|
||||
withContext(dispatchers.io) {
|
||||
container.unsubscribe(listOf(subscription.id))
|
||||
}
|
||||
jobs.cancel()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue