diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewContent.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewContent.kt index 555fb94..1a34bcb 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewContent.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewContent.kt @@ -46,6 +46,7 @@ fun PostViewContent( addRealEmojiViewModel: AddRealEmojiViewModel = hiltViewModel(), postRealEmojiListViewModel: MemberRealEmojiListViewModel = hiltViewModel(), addEmojiBarState: MutableState = remember { mutableStateOf(false) }, + postCommentDialogState: MutableState = remember { mutableStateOf(false) }, ) { val memberId = LocalSessionState.current.memberId val memberRealEmojiState by postRealEmojiListViewModel.uiState.collectAsState() @@ -150,6 +151,7 @@ fun PostViewContent( familyPostReactionBarViewModel = familyPostReactionBarViewModel, removePostReactionViewModel = removePostReactionViewModel, addPostReactionViewModel = addPostReactionViewModel, + postCommentDialogState = postCommentDialogState, ) } diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt index f77adff..1c4a237 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt @@ -22,6 +22,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.MutableState import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.key @@ -55,6 +56,7 @@ import com.no5ing.bbibbi.presentation.theme.bbibbiTypo import com.no5ing.bbibbi.util.LocalSessionState import com.no5ing.bbibbi.util.asyncImagePainter import com.no5ing.bbibbi.util.toLocalizedDate +import timber.log.Timber @OptIn(ExperimentalFoundationApi::class) @Composable @@ -71,6 +73,7 @@ fun PostViewPage( familyPostReactionBarViewModel: PostReactionBarViewModel = hiltViewModel(), removePostReactionViewModel: RemovePostReactionViewModel = hiltViewModel(), addPostReactionViewModel: AddPostReactionViewModel = hiltViewModel(), + postCommentDialogState: MutableState = remember { mutableStateOf(false) }, ) { LaunchedEffect(Unit) { familyPostViewModel.invoke(Arguments(resourceId = postId)) @@ -101,6 +104,18 @@ fun PostViewPage( ) } } + LaunchedEffect(postState, postCommentDialogState.value) { + if (!postCommentDialogState.value && postState.isReady()) { + val currentPost = postState.data.post + familyPostsViewModel.invoke( + Arguments( + arguments = mapOf( + "date" to currentPost.createdAt.toLocalDate().toString(), + ) + ) + ) + } + } LaunchedEffect(siblingPostState) { if (siblingPostState.isReady()) { isPagerReady = true @@ -161,6 +176,7 @@ fun PostViewPage( removePostReactionViewModel = removePostReactionViewModel, addPostReactionViewModel = addPostReactionViewModel, postData = postData, + postCommentDialogState = postCommentDialogState, ) } } else { @@ -172,6 +188,7 @@ fun PostViewPage( removePostReactionViewModel = removePostReactionViewModel, addPostReactionViewModel = addPostReactionViewModel, postData = postState.data, + postCommentDialogState = postCommentDialogState, ) } @@ -191,6 +208,7 @@ fun PostViewBody( familyPostReactionBarViewModel: PostReactionBarViewModel, removePostReactionViewModel: RemovePostReactionViewModel, addPostReactionViewModel: AddPostReactionViewModel, + postCommentDialogState: MutableState = remember { mutableStateOf(false) }, ) { Column { PostViewTopBar( @@ -208,6 +226,7 @@ fun PostViewBody( removePostReactionViewModel = removePostReactionViewModel, addPostReactionViewModel = addPostReactionViewModel, onTapRealEmojiCreate = onTapRealEmojiCreate, + postCommentDialogState = postCommentDialogState, ) } }