From e5b210d4e168084e4a8a846c15ebfd50ceef1c75 Mon Sep 17 00:00:00 2001 From: nrobi144 Date: Wed, 3 Jun 2026 09:36:18 +0300 Subject: [PATCH] fix(desktop): make first-pinned-feed default actually take effect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs that together caused HomeFeed to always open on Following: 1. FeedScreen was reading feedRepo.pinnedFeeds.value as the source of truth for the first pinned feed. That's a stateIn-derived flow with initial value persistentListOf(); the underlying _feeds StateFlow IS loaded synchronously by FeedDefinitionRepository on construction, but the derived pinnedFeeds doesn't reflect it until the first flow emission propagates — which is too late for `remember` to see. Fixed by reading feedRepo.feeds.value directly and filtering / sorting by pinOrder ourselves. 2. DeckColumnContainer was passing initialFeedMode = FeedMode.FOLLOWING when rendering DeckColumnType.HomeFeed, which overrode FeedScreen's first-pinned logic entirely. Removed the hardcode so the deck's home column inherits FeedScreen's default. With both fixed, a user who has only Global pinned now opens to Global on launch instead of Following. --- .../vitorpamplona/amethyst/desktop/ui/FeedScreen.kt | 11 ++++++++++- .../amethyst/desktop/ui/deck/DeckColumnContainer.kt | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) 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 7759865575..b4269a7745 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 @@ -436,7 +436,16 @@ fun FeedScreen( // not whatever DesktopPreferences happened to save last. If a caller // explicitly passes customFeedId/initialFeedMode, that always wins. val feedRepo = com.vitorpamplona.amethyst.desktop.ui.deck.LocalFeedRepository.current - val firstPinned = remember { feedRepo.pinnedFeeds.value.firstOrNull() } + // Read feeds.value (the source StateFlow that's loaded synchronously by + // FeedDefinitionRepository on construction) rather than pinnedFeeds.value — + // the latter is a stateIn-derived flow whose initial value is an empty list + // until the first flow emission propagates, which is too late for `remember`. + val firstPinned = + remember { + feedRepo.feeds.value + .filter { it.pinned } + .minByOrNull { it.pinOrder } + } val firstPinnedCustomSource = firstPinned?.source as? com.vitorpamplona.amethyst.commons.feeds.custom.FeedSource.Filter var activeFeedId by remember { diff --git a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckColumnContainer.kt b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckColumnContainer.kt index 90f0dbce05..7b673bf0e5 100644 --- a/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckColumnContainer.kt +++ b/desktopApp/src/jvmMain/kotlin/com/vitorpamplona/amethyst/desktop/ui/deck/DeckColumnContainer.kt @@ -327,6 +327,8 @@ internal fun RootContent( when (columnType) { DeckColumnType.HomeFeed -> { + // Don't hardcode initialFeedMode — let FeedScreen pick the first + // pinned feed (Following/Global/Custom) as the default tab. FeedScreen( relayManager = relayManager, localCache = localCache, @@ -334,7 +336,6 @@ internal fun RootContent( iAccount = iAccount, nwcConnection = nwcConnection, subscriptionsCoordinator = subscriptionsCoordinator, - initialFeedMode = FeedMode.FOLLOWING, onCompose = onShowComposeDialog, onNavigateToProfile = onNavigateToProfile, onNavigateToThread = onNavigateToThread,