From 562cd3355b36d363ca460ca1d8339e29773099b4 Mon Sep 17 00:00:00 2001 From: nrobi144 Date: Sat, 23 May 2026 14:02:48 +0300 Subject: [PATCH] fix(desktop): fix feed cold-boot race and remove NWC diagnostic println Add LaunchedEffect that rescans cache when followedUsers populates after startup, fixing empty feed when contact list arrives after initial scan. Remove diagnostic println from NwcPaymentHandler. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../amethyst/desktop/nwc/NwcPaymentHandler.kt | 1 - .../com/vitorpamplona/amethyst/desktop/ui/FeedScreen.kt | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandler.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandler.kt index 7171e85b40..f21c341df8 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandler.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/nwc/NwcPaymentHandler.kt @@ -322,7 +322,6 @@ class NwcPaymentHandler( subId = subId, filters = listOf(filter), onEvent = { event, _ -> - println("NWC rpc event received: kind=${event.kind} id=${event.id.take(8)} from=${event.pubKey.take(8)}") if (event is LnZapPaymentResponseEvent && event.requestId() == requestId) { @OptIn(kotlinx.coroutines.DelicateCoroutinesApi::class) kotlinx.coroutines.GlobalScope.launch(kotlinx.coroutines.Dispatchers.IO) { diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/FeedScreen.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/FeedScreen.kt index c7cd0ea925..744762c5af 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/FeedScreen.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/FeedScreen.kt @@ -409,6 +409,14 @@ fun FeedScreen( onDispose { viewModel.destroy() } } + // Rescan cache when followedUsers populates (fixes cold-boot race where + // the initial scan runs before the contact list arrives from relays) + LaunchedEffect(viewModel, followedUsers) { + if (feedMode == FeedMode.FOLLOWING && followedUsers.isNotEmpty()) { + viewModel.feedState.refreshSuspended() + } + } + val feedState by viewModel.feedState.feedContent.collectAsState() // Viewport-aware metadata loading: only fetch for visible notes + buffer