From 2ed0ca5fdb44f440346c64115f1ffd546f018492 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 13 Feb 2023 15:50:50 -0500 Subject: [PATCH] Removing DataSource stops in ViewModels to make sure this is handled by the Screen class --- .../amethyst/ui/screen/CardFeedViewModel.kt | 3 --- .../vitorpamplona/amethyst/ui/screen/FeedViewModel.kt | 11 +---------- .../amethyst/ui/screen/LnZapFeedViewModel.kt | 3 --- .../amethyst/ui/screen/UserFeedViewModel.kt | 3 --- 4 files changed, 1 insertion(+), 19 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/CardFeedViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/CardFeedViewModel.kt index bbfc83ac4..905e4a4f8 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/CardFeedViewModel.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/CardFeedViewModel.kt @@ -141,9 +141,6 @@ class CardFeedViewModel(val dataSource: NostrDataSource): ViewModel() { override fun onCleared() { LocalCache.live.removeObserver(cacheListener) - - dataSource.stop() - viewModelScope.cancel() super.onCleared() } } \ No newline at end of file diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt index c645d5ca0..a7b692a3e 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedViewModel.kt @@ -1,8 +1,6 @@ package com.vitorpamplona.amethyst.ui.screen -import android.util.Log import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.model.LocalCache @@ -16,20 +14,16 @@ import com.vitorpamplona.amethyst.service.NostrGlobalDataSource import com.vitorpamplona.amethyst.service.NostrHomeDataSource import com.vitorpamplona.amethyst.service.NostrThreadDataSource import com.vitorpamplona.amethyst.service.NostrUserProfileDataSource -import com.vitorpamplona.amethyst.service.NostrUserProfileZapsDataSource -import com.vitorpamplona.amethyst.service.model.RepostEvent +import java.util.concurrent.atomic.AtomicBoolean import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job -import kotlinx.coroutines.cancel import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import nostr.postr.events.TextNoteEvent -import java.util.concurrent.atomic.AtomicBoolean class NostrChannelFeedViewModel: FeedViewModel(NostrChannelDataSource) class NostrChatRoomFeedViewModel: FeedViewModel(NostrChatRoomDataSource) @@ -139,9 +133,6 @@ abstract class FeedViewModel(val dataSource: NostrDataSource): ViewModel() override fun onCleared() { LocalCache.live.removeObserver(cacheListener) - - dataSource.stop() - viewModelScope.cancel() super.onCleared() } } \ No newline at end of file diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/LnZapFeedViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/LnZapFeedViewModel.kt index 8a4662837..5f465ff74 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/LnZapFeedViewModel.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/LnZapFeedViewModel.kt @@ -87,9 +87,6 @@ open class LnZapFeedViewModel(val dataSource: NostrDataSource>) override fun onCleared() { LocalCache.live.removeObserver(cacheListener) - - dataSource.stop() - viewModelScope.cancel() super.onCleared() } } \ No newline at end of file diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedViewModel.kt index 495e635ab..ec7c31dd2 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedViewModel.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedViewModel.kt @@ -102,9 +102,6 @@ open class UserFeedViewModel(val dataSource: NostrDataSource): ViewModel() override fun onCleared() { LocalCache.live.removeObserver(cacheListener) - - dataSource.stop() - viewModelScope.cancel() super.onCleared() } } \ No newline at end of file