Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
Expand Down Expand Up @@ -67,7 +66,6 @@ fun DeleteWriteDiaryBottomSheet(
)
}
Spacer(modifier = Modifier.navigationBarsPadding())
Spacer(modifier = Modifier.height(60.dp))
}
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ fun WriteDiaryRoute(
failureMessage = failureMessage,
showExitDialog = showExitDialog,
onClickBack = {
if (viewModel.hasChangedFromInitial()) {
AmplitudeUtils.trackEvent(AmplitudeConstraints.WRITING_DIARY_BACK)
viewModel.updateShowExitDialog(true)
} else {
AmplitudeUtils.trackEvent(AmplitudeConstraints.WRITING_DIARY_BACK)
if (!viewModel.hasChangedFromInitial()) {
navigateToPrevious()
} else {
viewModel.updateShowExitDialog(true)
}
},
Comment on lines 116 to 123
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify consistency in event tracking between BackHandler and onClickBack.

The logic correctly implements the requirement to always track the back event and navigate immediately when no changes exist. However, there's an inconsistency with the BackHandler (lines 96-98) which only tracks the event when changes are detected, while this callback always tracks it.

Consider whether both handlers should have consistent event tracking behavior:


🏁 Script executed:

#!/bin/bash
# Search for other usages of WRITING_DIARY_BACK event to understand the intended tracking pattern
rg -A 3 -B 3 "WRITING_DIARY_BACK"

Length of output: 2808


Align BackHandler’s event tracking with onClickBack

The system back handler currently only logs the back event when changes exist, whereas the UI back button always logs it. To ensure consistent analytics, move the trackEvent call outside the change check in the BackHandler.

• File: app/src/main/java/com/sopt/clody/presentation/ui/writediary/screen/WriteDiaryScreen.kt
– BackHandler block (around lines 92–103)

Suggested diff:

 BackHandler {
-    if (viewModel.hasChangedFromInitial()) {
-        AmplitudeUtils.trackEvent(AmplitudeConstraints.WRITING_DIARY_BACK)
-        viewModel.updateShowExitDialog(true)
-    } else {
-        navigateToPrevious()
-    }
+    AmplitudeUtils.trackEvent(AmplitudeConstraints.WRITING_DIARY_BACK)
+    if (viewModel.hasChangedFromInitial()) {
+        viewModel.updateShowExitDialog(true)
+    } else {
+        navigateToPrevious()
+    }
 }
🤖 Prompt for AI Agents
In
app/src/main/java/com/sopt/clody/presentation/ui/writediary/screen/WriteDiaryScreen.kt
around lines 92 to 103, the BackHandler currently tracks the WRITING_DIARY_BACK
event only when changes exist, unlike the onClickBack handler which always
tracks it. To fix this inconsistency, move the
AmplitudeUtils.trackEvent(AmplitudeConstraints.WRITING_DIARY_BACK) call outside
and before the conditional check in the BackHandler so that the event is always
tracked regardless of changes.

onClickAdd = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ class WriteDiaryViewModel @Inject constructor(
}

fun hasChangedFromInitial(): Boolean {
return entries != initialEntries
if (initialEntries.isEmpty()) return false
val current = entries.map { it.trim() }
val initial = initialEntries.map { it.trim() }
return current != initial
}

fun fetchDraftDiary(year: Int, month: Int, day: Int) {
Expand Down