Skip to content

Commit

Permalink
Solving viewModel creation bug for Public Bookmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorpamplona committed Jan 11, 2024
1 parent 422446f commit 81400eb
Showing 1 changed file with 15 additions and 3 deletions.
Expand Up @@ -44,21 +44,20 @@ 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,
nav: (String) -> Unit,
) {
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),
)

Expand All @@ -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()
Expand Down Expand Up @@ -99,6 +110,7 @@ fun BookmarkListScreen(
accountViewModel = accountViewModel,
nav = nav,
)

1 ->
RefresheableFeedView(
publicFeedViewModel,
Expand Down

0 comments on commit 81400eb

Please sign in to comment.