From 533e7d661f2d78b761bc4ac2c4be3b87168c3138 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 29 Apr 2025 14:36:01 -0400 Subject: [PATCH] Presubscribe to the bottom navigation items in the start up of the app. --- .../account/AccountFilterAssemblerSubscription.kt | 3 +-- .../amethyst/ui/screen/loggedIn/LoggedInPage.kt | 9 +++++++++ .../ChatroomListFilterAssemblerSubscription.kt | 8 ++++++++ .../chats/rooms/singlepane/MessagesSinglePane.kt | 2 +- .../loggedIn/chats/rooms/twopane/ChatroomListPane.kt | 2 +- .../datasource/DiscoveryFilterAssemblerSubscription.kt | 8 ++++++++ .../amethyst/ui/screen/loggedIn/home/HomeScreen.kt | 3 ++- .../home/datasource/HomeFilterAssemblerSubscription.kt | 8 ++++++++ .../amethyst/ui/screen/loggedIn/video/VideoScreen.kt | 2 +- .../video/datasource/VideoFilterAssemblerSubscription.kt | 8 ++++++++ 10 files changed, 47 insertions(+), 6 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/AccountFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/AccountFilterAssemblerSubscription.kt index c37727854..8e2e16670 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/AccountFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/AccountFilterAssemblerSubscription.kt @@ -22,12 +22,11 @@ package com.vitorpamplona.amethyst.service.relayClient.reqCommand.account import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.service.relayClient.KeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @Composable -fun AccountFilterAssemblerSubscription(accountViewModel: AccountViewModel) = AccountFilterAssemblerSubscription(accountViewModel, Amethyst.instance.sources.account) +fun AccountFilterAssemblerSubscription(accountViewModel: AccountViewModel) = AccountFilterAssemblerSubscription(accountViewModel, accountViewModel.dataSources().account) @Composable fun AccountFilterAssemblerSubscription( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/LoggedInPage.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/LoggedInPage.kt index 65f8058e7..3db70dac4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/LoggedInPage.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/LoggedInPage.kt @@ -50,6 +50,10 @@ import com.vitorpamplona.amethyst.ui.navigation.AppNavigation import com.vitorpamplona.amethyst.ui.navigation.Route import com.vitorpamplona.amethyst.ui.screen.AccountStateViewModel import com.vitorpamplona.amethyst.ui.screen.SharedPreferencesViewModel +import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.rooms.datasource.ChatroomListFilterAssemblerSubscription +import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.datasource.DiscoveryFilterAssemblerSubscription +import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.datasource.HomeFilterAssemblerSubscription +import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.VideoFilterAssemblerSubscription import com.vitorpamplona.amethyst.ui.tor.TorServiceStatus import com.vitorpamplona.amethyst.ui.tor.TorType import com.vitorpamplona.quartz.nip55AndroidSigner.NostrSignerExternal @@ -83,6 +87,11 @@ fun LoggedInPage( // Loads account information from Relays. AccountFilterAssemblerSubscription(accountViewModel) + HomeFilterAssemblerSubscription(accountViewModel) + ChatroomListFilterAssemblerSubscription(accountViewModel) + VideoFilterAssemblerSubscription(accountViewModel) + DiscoveryFilterAssemblerSubscription(accountViewModel) + // TODO: Is this needed? RelaySubscriptionsCoordinatorSubscription() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/ChatroomListFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/ChatroomListFilterAssemblerSubscription.kt index fbd5598da..4415f8107 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/ChatroomListFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/ChatroomListFilterAssemblerSubscription.kt @@ -25,6 +25,14 @@ import androidx.compose.runtime.remember import com.vitorpamplona.amethyst.service.relayClient.KeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +@Composable +fun ChatroomListFilterAssemblerSubscription(accountViewModel: AccountViewModel) { + ChatroomListFilterAssemblerSubscription( + accountViewModel.dataSources().chatroomList, + accountViewModel, + ) +} + @Composable fun ChatroomListFilterAssemblerSubscription( dataSource: ChatroomListFilterAssembler, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/singlepane/MessagesSinglePane.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/singlepane/MessagesSinglePane.kt index 19765d649..605ff7918 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/singlepane/MessagesSinglePane.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/singlepane/MessagesSinglePane.kt @@ -57,7 +57,7 @@ fun MessagesSinglePane( WatchLifecycleAndUpdateModel(knownFeedContentState) WatchLifecycleAndUpdateModel(newFeedContentState) - ChatroomListFilterAssemblerSubscription(accountViewModel.dataSources().chatroomList, accountViewModel) + ChatroomListFilterAssemblerSubscription(accountViewModel) val tabs by remember(knownFeedContentState, markKnownAsRead) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/twopane/ChatroomListPane.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/twopane/ChatroomListPane.kt index cee6c8bcf..0cf2db2da 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/twopane/ChatroomListPane.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/twopane/ChatroomListPane.kt @@ -54,7 +54,7 @@ fun ChatroomList( WatchLifecycleAndUpdateModel(knownFeedContentState) WatchLifecycleAndUpdateModel(newFeedContentState) - ChatroomListFilterAssemblerSubscription(accountViewModel.dataSources().chatroomList, accountViewModel) + ChatroomListFilterAssemblerSubscription(accountViewModel) val tabs by remember(knownFeedContentState, markKnownAsRead) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFilterAssemblerSubscription.kt index 29cf4be8c..759770ffb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/datasource/DiscoveryFilterAssemblerSubscription.kt @@ -26,6 +26,14 @@ import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.service.relayClient.KeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +@Composable +fun DiscoveryFilterAssemblerSubscription(accountViewModel: AccountViewModel) { + DiscoveryFilterAssemblerSubscription( + accountViewModel.dataSources().discovery, + accountViewModel, + ) +} + @Composable fun DiscoveryFilterAssemblerSubscription( dataSource: DiscoveryFilterAssembler, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt index 8558bd122..5faa61745 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt @@ -96,7 +96,8 @@ fun HomeScreen( WatchLifecycleAndUpdateModel(newThreadsFeedState) WatchLifecycleAndUpdateModel(repliesFeedState) - HomeFilterAssemblerSubscription(accountViewModel.dataSources().home, accountViewModel) + + HomeFilterAssemblerSubscription(accountViewModel) AssembleHomeTabs(newThreadsFeedState, repliesFeedState) { pagerState, tabItems -> HomePages(pagerState, tabItems, accountViewModel, nav) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/HomeFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/HomeFilterAssemblerSubscription.kt index 1ddbcc4c1..00b74a788 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/HomeFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/HomeFilterAssemblerSubscription.kt @@ -26,6 +26,14 @@ import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.service.relayClient.KeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +@Composable +fun HomeFilterAssemblerSubscription(accountViewModel: AccountViewModel) { + HomeFilterAssemblerSubscription( + accountViewModel.dataSources().home, + accountViewModel, + ) +} + @Composable fun HomeFilterAssemblerSubscription( dataSource: HomeFilterAssembler, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt index 3a6201575..848f22cd7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt @@ -124,7 +124,7 @@ fun VideoScreen( ) { WatchLifecycleAndUpdateModel(videoFeedContentState) WatchAccountForVideoScreen(videoFeedContentState = videoFeedContentState, accountViewModel = accountViewModel) - VideoFilterAssemblerSubscription(accountViewModel.dataSources().video, accountViewModel) + VideoFilterAssemblerSubscription(accountViewModel) DisappearingScaffold( isInvertedLayout = false, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/VideoFilterAssemblerSubscription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/VideoFilterAssemblerSubscription.kt index 84dfa1057..cd8bbc0ef 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/VideoFilterAssemblerSubscription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/VideoFilterAssemblerSubscription.kt @@ -26,6 +26,14 @@ import androidx.lifecycle.viewModelScope import com.vitorpamplona.amethyst.service.relayClient.KeyDataSourceSubscription import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel +@Composable +fun VideoFilterAssemblerSubscription(accountViewModel: AccountViewModel) { + VideoFilterAssemblerSubscription( + accountViewModel.dataSources().video, + accountViewModel, + ) +} + @Composable fun VideoFilterAssemblerSubscription( filterAssembler: VideoFilterAssembler,