fix: key ViewModels to prevent incorrect re-use

This commit is contained in:
Harsh Shandilya 2025-05-29 23:45:37 +05:30
parent 931684f76b
commit bebbe4f82c
2 changed files with 2 additions and 2 deletions

View file

@ -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

View file

@ -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) {