From 81400eb863cdca70ad65f78eeb295e2c3ffd340a Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Thu, 11 Jan 2024 10:36:52 -0500 Subject: [PATCH] Solving viewModel creation bug for Public Bookmarks --- .../ui/screen/loggedIn/BookmarkListScreen.kt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/BookmarkListScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/BookmarkListScreen.kt index cc4847078..1926b39d0 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/BookmarkListScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/BookmarkListScreen.kt @@ -44,7 +44,6 @@ import com.vitorpamplona.amethyst.ui.screen.RefresheableFeedView import com.vitorpamplona.amethyst.ui.theme.TabRowHeight import kotlinx.coroutines.launch -@OptIn(ExperimentalFoundationApi::class) @Composable fun BookmarkListScreen( accountViewModel: AccountViewModel, @@ -52,13 +51,13 @@ fun BookmarkListScreen( ) { val publicFeedViewModel: NostrBookmarkPublicFeedViewModel = viewModel( - key = "NotificationViewModel", + key = "NostrBookmarkPublicFeedViewModel", factory = NostrBookmarkPublicFeedViewModel.Factory(accountViewModel.account), ) val privateFeedViewModel: NostrBookmarkPrivateFeedViewModel = viewModel( - key = "NotificationViewModel", + key = "NostrBookmarkPrivateFeedViewModel", factory = NostrBookmarkPrivateFeedViewModel.Factory(accountViewModel.account), ) @@ -69,6 +68,18 @@ fun BookmarkListScreen( privateFeedViewModel.invalidateData() } + + RenderBookmarkScreen(privateFeedViewModel, accountViewModel, nav, publicFeedViewModel) +} + +@Composable +@OptIn(ExperimentalFoundationApi::class) +private fun RenderBookmarkScreen( + privateFeedViewModel: NostrBookmarkPrivateFeedViewModel, + accountViewModel: AccountViewModel, + nav: (String) -> Unit, + publicFeedViewModel: NostrBookmarkPublicFeedViewModel, +) { Column(Modifier.fillMaxHeight()) { val pagerState = rememberPagerState { 2 } val coroutineScope = rememberCoroutineScope() @@ -99,6 +110,7 @@ fun BookmarkListScreen( accountViewModel = accountViewModel, nav = nav, ) + 1 -> RefresheableFeedView( publicFeedViewModel,