From bebbe4f82c9c8b45da6885bb487d6b03b926cd65 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 29 May 2025 23:45:37 +0530 Subject: [PATCH] fix: key ViewModels to prevent incorrect re-use --- .../kotlin/dev/msfjarvis/claw/common/comments/CommentsPage.kt | 2 +- .../main/kotlin/dev/msfjarvis/claw/common/user/UserProfile.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentsPage.kt b/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentsPage.kt index 194d5a41..bd6916d3 100644 --- a/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentsPage.kt +++ b/common/src/main/kotlin/dev/msfjarvis/claw/common/comments/CommentsPage.kt @@ -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 diff --git a/common/src/main/kotlin/dev/msfjarvis/claw/common/user/UserProfile.kt b/common/src/main/kotlin/dev/msfjarvis/claw/common/user/UserProfile.kt index 9005d237..3c36b954 100644 --- a/common/src/main/kotlin/dev/msfjarvis/claw/common/user/UserProfile.kt +++ b/common/src/main/kotlin/dev/msfjarvis/claw/common/user/UserProfile.kt @@ -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) {