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 ea53ef5ed..600e8ec5d 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,7 +79,6 @@ 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.ListsAndSetsScreen -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.lists.followsets.FollowSetsManagementDialog import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.NotificationScreen @@ -110,7 +109,6 @@ import java.net.URI fun AppNavigation( accountViewModel: AccountViewModel, accountStateViewModel: AccountStateViewModel, - listsViewModel: NostrUserListFeedViewModel, ) { val nav = rememberNav() @@ -127,12 +125,12 @@ fun AppNavigation( composable { DiscoverScreen(accountViewModel, nav) } composable { NotificationScreen(accountViewModel, nav) } - composableFromEnd { ListsAndSetsScreen(accountViewModel, listsViewModel, nav) } + composableFromEnd { ListsAndSetsScreen(accountViewModel, nav) } composableArgs { - FollowSetScreen(it.setIdentifier, accountViewModel, listsViewModel, nav) + FollowSetScreen(it.setIdentifier, accountViewModel, nav) } composableArgs { - FollowSetsManagementDialog(it.userHexKey, accountViewModel.account, listsViewModel, nav) + FollowSetsManagementDialog(it.userHexKey, accountViewModel, nav) } composable { NewUserMetadataScreen(nav, accountViewModel) } 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 a5c198852..23a3da0e8 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,7 +50,6 @@ import com.vitorpamplona.amethyst.ui.screen.AccountStateViewModel 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 com.vitorpamplona.quartz.utils.Log @@ -75,12 +74,6 @@ 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. @@ -107,7 +100,6 @@ fun LoggedInPage( AppNavigation( accountViewModel = accountViewModel, accountStateViewModel = accountStateViewModel, - 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 4a8516584..26f2a4dc3 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 @@ -58,6 +58,7 @@ 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 @@ -74,7 +75,25 @@ import kotlinx.coroutines.launch @Composable fun ListsAndSetsScreen( accountViewModel: AccountViewModel, + nav: INav, +) { + val followSetsViewModel: NostrUserListFeedViewModel = + viewModel( + key = "NostrUserListFeedViewModel", + factory = NostrUserListFeedViewModel.Factory(accountViewModel.account), + ) + + ListsAndSetsScreen( + followSetsViewModel, + accountViewModel, + nav, + ) +} + +@Composable +fun ListsAndSetsScreen( followSetsViewModel: NostrUserListFeedViewModel, + accountViewModel: AccountViewModel, nav: INav, ) { val lifeCycleOwner = LocalLifecycleOwner.current 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 436b0223f..1eda66dbb 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,6 +60,7 @@ 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 @@ -83,7 +84,23 @@ import kotlinx.coroutines.launch fun FollowSetScreen( selectedSetIdentifier: String, accountViewModel: AccountViewModel, + navigator: INav, +) { + val followSetViewModel: NostrUserListFeedViewModel = + viewModel( + key = "NostrUserListFeedViewModel", + factory = NostrUserListFeedViewModel.Factory(accountViewModel.account), + ) + + FollowSetScreen(selectedSetIdentifier, followSetViewModel, accountViewModel, navigator) +} + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun FollowSetScreen( + selectedSetIdentifier: String, followSetViewModel: NostrUserListFeedViewModel, + accountViewModel: AccountViewModel, navigator: INav, ) { val followSetState by followSetViewModel.feedContent.collectAsState() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/followsets/FollowSetsManagementDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/followsets/FollowSetsManagementDialog.kt index 1763f43d6..5b3839880 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/followsets/FollowSetsManagementDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/followsets/FollowSetsManagementDialog.kt @@ -74,11 +74,13 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.Dp 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.Account import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.ui.navigation.navs.INav import com.vitorpamplona.amethyst.ui.note.ArrowBackIcon +import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.FollowSetState import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.ListVisibility import com.vitorpamplona.amethyst.ui.screen.loggedIn.lists.NewSetCreationDialog @@ -92,8 +94,24 @@ import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer @Composable fun FollowSetsManagementDialog( userHex: String, - account: Account, + accountViewModel: AccountViewModel, + navigator: INav, +) { + val followSetViewModel: NostrUserListFeedViewModel = + viewModel( + key = "NostrUserListFeedViewModel", + factory = NostrUserListFeedViewModel.Factory(accountViewModel.account), + ) + + FollowSetsManagementDialog(userHex, followSetViewModel, accountViewModel.account, navigator) +} + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun FollowSetsManagementDialog( + userHex: String, followSetsViewModel: NostrUserListFeedViewModel, + account: Account, navigator: INav, ) { val followSetsState by followSetsViewModel.feedContent.collectAsState()