mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 06:17:37 +02:00
Moving the ThreadView to the same Model as Global: Only active when using this view.
This commit is contained in:
@@ -51,7 +51,7 @@ object ServiceManager {
|
|||||||
NostrSingleEventDataSource.start()
|
NostrSingleEventDataSource.start()
|
||||||
NostrSingleChannelDataSource.start()
|
NostrSingleChannelDataSource.start()
|
||||||
NostrSingleUserDataSource.start()
|
NostrSingleUserDataSource.start()
|
||||||
NostrThreadDataSource.start()
|
//NostrThreadDataSource.start()
|
||||||
NostrChatroomListDataSource.start()
|
NostrChatroomListDataSource.start()
|
||||||
} else {
|
} else {
|
||||||
// if not logged in yet, start a basic service wit default relays
|
// if not logged in yet, start a basic service wit default relays
|
||||||
|
@@ -8,19 +8,40 @@ import androidx.compose.runtime.DisposableEffect
|
|||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.livedata.observeAsState
|
import androidx.compose.runtime.livedata.observeAsState
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalLifecycleOwner
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.lifecycle.LifecycleEventObserver
|
||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import com.vitorpamplona.amethyst.service.NostrThreadDataSource
|
import com.vitorpamplona.amethyst.service.NostrThreadDataSource
|
||||||
|
import com.vitorpamplona.amethyst.service.NostrUserProfileDataSource
|
||||||
|
import com.vitorpamplona.amethyst.service.NostrUserProfileFollowersDataSource
|
||||||
|
import com.vitorpamplona.amethyst.service.NostrUserProfileFollowsDataSource
|
||||||
|
import com.vitorpamplona.amethyst.service.NostrUserProfileZapsDataSource
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ThreadScreen(noteId: String?, accountViewModel: AccountViewModel, navController: NavController) {
|
fun ThreadScreen(noteId: String?, accountViewModel: AccountViewModel, navController: NavController) {
|
||||||
val account by accountViewModel.accountLiveData.observeAsState()
|
val account by accountViewModel.accountLiveData.observeAsState()
|
||||||
|
|
||||||
DisposableEffect(account) {
|
val lifeCycleOwner = LocalLifecycleOwner.current
|
||||||
|
|
||||||
|
DisposableEffect(accountViewModel) {
|
||||||
|
val observer = LifecycleEventObserver { source, event ->
|
||||||
|
if (event == Lifecycle.Event.ON_RESUME) {
|
||||||
|
println("Thread Start")
|
||||||
|
NostrThreadDataSource.start()
|
||||||
|
}
|
||||||
|
if (event == Lifecycle.Event.ON_PAUSE) {
|
||||||
|
println("Thread Stop")
|
||||||
|
NostrThreadDataSource.stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lifeCycleOwner.lifecycle.addObserver(observer)
|
||||||
onDispose {
|
onDispose {
|
||||||
NostrThreadDataSource.stop()
|
lifeCycleOwner.lifecycle.removeObserver(observer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user