mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-15 08:47:03 +05:30
fix: key ViewModels to prevent incorrect re-use
This commit is contained in:
parent
931684f76b
commit
bebbe4f82c
2 changed files with 2 additions and 2 deletions
|
@ -36,7 +36,7 @@ fun CommentsPage(
|
|||
contentPadding: PaddingValues,
|
||||
openUserProfile: (String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
viewModel: CommentsViewModel = injectedViewModel(),
|
||||
viewModel: CommentsViewModel = injectedViewModel(key = postId),
|
||||
) {
|
||||
LaunchedEffect(postId) { viewModel.loadPostDetails(postId) }
|
||||
val commentState by
|
||||
|
|
|
@ -44,7 +44,7 @@ fun UserProfile(
|
|||
contentPadding: PaddingValues,
|
||||
openUserProfile: (String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
viewModel: UserProfileViewModel = injectedViewModel(),
|
||||
viewModel: UserProfileViewModel = injectedViewModel(key = username),
|
||||
) {
|
||||
LaunchedEffect(username) { viewModel.loadProfile(username) }
|
||||
when (val state = viewModel.userProfile) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue