diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt index cd981f651..a355bb7f9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/AppNavigation.kt @@ -79,6 +79,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.hashtag.HashtagScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.HomeScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.home.ShortNotePostScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.ListsScreen +import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.NostrUserListFeedViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.followsets.FollowSetScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.NotificationScreen import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.publicMessages.NewPublicMessageScreen @@ -109,6 +110,7 @@ fun AppNavigation( accountViewModel: AccountViewModel, accountStateViewModel: AccountStateViewModel, sharedPreferencesViewModel: SharedPreferencesViewModel, + listsViewModel: NostrUserListFeedViewModel, ) { val nav = rememberNav() @@ -125,9 +127,9 @@ fun AppNavigation( composable { DiscoverScreen(accountViewModel, nav) } composable { NotificationScreen(sharedPreferencesViewModel, accountViewModel, nav) } - composableFromEnd { ListsScreen(accountViewModel, nav) } + composableFromEnd { ListsScreen(accountViewModel, listsViewModel, nav) } composableArgs { - FollowSetScreen(it.setIdentifier, accountViewModel, nav) + FollowSetScreen(it.setIdentifier, accountViewModel, listsViewModel, nav) } composable { NewUserMetadataScreen(nav, accountViewModel) } @@ -144,7 +146,7 @@ fun AppNavigation( composableFromEndArgs { AllMediaServersScreen(accountViewModel, nav) } composableFromEndArgs { DvmContentDiscoveryScreen(it.id, accountViewModel, nav) } - composableFromEndArgs { ProfileScreen(it.id, accountViewModel, nav) } + composableFromEndArgs { ProfileScreen(it.id, accountViewModel, listsViewModel, nav) } composableFromEndArgs { ThreadScreen(it.id, accountViewModel, nav) } composableFromEndArgs { HashtagScreen(it, accountViewModel, nav) } composableFromEndArgs { GeoHashScreen(it, accountViewModel, nav) } 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 3762c4d27..8168266bd 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 @@ -53,6 +53,7 @@ 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.lists.NostrUserListFeedViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.video.datasource.VideoFilterAssemblerSubscription import com.vitorpamplona.quartz.nip55AndroidSigner.client.IActivityLauncher import kotlinx.coroutines.launch @@ -75,6 +76,12 @@ fun LoggedInPage( ), ) + val listsViewModel: NostrUserListFeedViewModel = + viewModel( + key = "NostrUserListFeedViewModel", + factory = NostrUserListFeedViewModel.Factory(accountViewModel.account), + ) + accountViewModel.firstRoute = route // Adds this account to the authentication procedures for relays. @@ -111,6 +118,7 @@ fun LoggedInPage( accountViewModel = accountViewModel, accountStateViewModel = accountStateViewModel, sharedPreferencesViewModel = sharedPreferencesViewModel, + listsViewModel = listsViewModel, ) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/CustomListsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/CustomListsScreen.kt index c8047213b..5fc23f677 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/CustomListsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/CustomListsScreen.kt @@ -56,7 +56,6 @@ import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.lifecycle.viewmodel.compose.viewModel import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.ui.layouts.DisappearingScaffold import com.vitorpamplona.amethyst.ui.navigation.navs.INav @@ -73,15 +72,9 @@ import kotlinx.coroutines.launch @Composable fun ListsScreen( accountViewModel: AccountViewModel, + followSetsViewModel: NostrUserListFeedViewModel, nav: INav, ) { - val followSetsViewModel: NostrUserListFeedViewModel = - viewModel( - key = "NostrUserListFeedViewModel", - factory = NostrUserListFeedViewModel.Factory(accountViewModel.account), - ) - - val currentCoroutineScope = rememberCoroutineScope() val lifeCycleOwner = LocalLifecycleOwner.current DisposableEffect(lifeCycleOwner) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/followsets/FollowSetScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/followsets/FollowSetScreen.kt index 2ffbe111f..436b0223f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/followsets/FollowSetScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/followsets/FollowSetScreen.kt @@ -60,7 +60,6 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import androidx.lifecycle.viewmodel.compose.viewModel import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.model.User import com.vitorpamplona.amethyst.ui.components.ClickableBox @@ -84,14 +83,9 @@ import kotlinx.coroutines.launch fun FollowSetScreen( selectedSetIdentifier: String, accountViewModel: AccountViewModel, + followSetViewModel: NostrUserListFeedViewModel, navigator: INav, ) { - val followSetViewModel: NostrUserListFeedViewModel = - viewModel( - key = "NostrUserListFeedViewModel", - factory = NostrUserListFeedViewModel.Factory(accountViewModel.account), - ) - val followSetState by followSetViewModel.feedContent.collectAsState() val uiScope = rememberCoroutineScope() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/ProfileScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/ProfileScreen.kt index a578e8712..c17d273d3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/ProfileScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/ProfileScreen.kt @@ -104,6 +104,7 @@ import kotlinx.coroutines.launch fun ProfileScreen( userId: String?, accountViewModel: AccountViewModel, + nostrListsViewModel: NostrUserListFeedViewModel, nav: INav, ) { if (userId == null) return @@ -123,6 +124,7 @@ fun ProfileScreen( PrepareViewModels( baseUser = it, accountViewModel = accountViewModel, + nostrListsViewModel = nostrListsViewModel, nav = nav, ) } @@ -132,6 +134,7 @@ fun ProfileScreen( fun PrepareViewModels( baseUser: User, accountViewModel: AccountViewModel, + nostrListsViewModel: NostrUserListFeedViewModel, nav: INav, ) { val followsFeedViewModel: UserProfileFollowsUserFeedViewModel = @@ -228,15 +231,6 @@ fun PrepareViewModels( ), ) - val followSetsViewModel: NostrUserListFeedViewModel = - viewModel( - key = "NostrUserListFeedViewModel", - factory = - NostrUserListFeedViewModel.Factory( - accountViewModel.account, - ), - ) - ProfileScreen( baseUser = baseUser, threadsViewModel, @@ -249,7 +243,7 @@ fun PrepareViewModels( bookmarksFeedViewModel, galleryFeedViewModel, reportsFeedViewModel, - followSetsViewModel, + nostrListsViewModel, accountViewModel = accountViewModel, nav = nav, )