mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-15 05:17: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,
|
contentPadding: PaddingValues,
|
||||||
openUserProfile: (String) -> Unit,
|
openUserProfile: (String) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
viewModel: CommentsViewModel = injectedViewModel(),
|
viewModel: CommentsViewModel = injectedViewModel(key = postId),
|
||||||
) {
|
) {
|
||||||
LaunchedEffect(postId) { viewModel.loadPostDetails(postId) }
|
LaunchedEffect(postId) { viewModel.loadPostDetails(postId) }
|
||||||
val commentState by
|
val commentState by
|
||||||
|
|
|
@ -44,7 +44,7 @@ fun UserProfile(
|
||||||
contentPadding: PaddingValues,
|
contentPadding: PaddingValues,
|
||||||
openUserProfile: (String) -> Unit,
|
openUserProfile: (String) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
viewModel: UserProfileViewModel = injectedViewModel(),
|
viewModel: UserProfileViewModel = injectedViewModel(key = username),
|
||||||
) {
|
) {
|
||||||
LaunchedEffect(username) { viewModel.loadProfile(username) }
|
LaunchedEffect(username) { viewModel.loadProfile(username) }
|
||||||
when (val state = viewModel.userProfile) {
|
when (val state = viewModel.userProfile) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue