mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-10 00:16:59 +00:00
fix(desktop): make first-pinned-feed default actually take effect
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.
This commit is contained in:
@@ -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 {
|
||||
|
||||
+2
-1
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user