From 84f10da006513c41a37697e988144a9b5f217642 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 24 Mar 2025 18:02:55 -0400 Subject: [PATCH] Forces the root post in a thread to be observed at all times. That guarantees thread loading even if relays are slow and the user is scrolling. --- .../ui/screen/loggedIn/threadview/ThreadScreen.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadScreen.kt index 40819be48..5bb86f7e5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/threadview/ThreadScreen.kt @@ -25,6 +25,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.livedata.observeAsState import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.lifecycle.Lifecycle @@ -32,6 +33,7 @@ import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.viewmodel.compose.viewModel import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.service.NostrThreadDataSource +import com.vitorpamplona.amethyst.ui.components.LoadNote import com.vitorpamplona.amethyst.ui.navigation.INav import com.vitorpamplona.amethyst.ui.navigation.TopBarExtensibleWithBackButton import com.vitorpamplona.amethyst.ui.screen.NostrThreadFeedViewModel @@ -85,6 +87,13 @@ fun ThreadScreen( onDispose { lifeCycleOwner.lifecycle.removeObserver(observer) } } + LoadNote(noteId, accountViewModel) { + if (it != null) { + // this will force loading every post from this thread. + val metadata = it.live().metadata.observeAsState() + } + } + DisappearingScaffold( isInvertedLayout = false, topBar = {