Skip to content

[REFACTOR/#276] 일기작성 뒤로가기 수정 및 삭제 바텀시트 UI 수정을 진행합니다.#277

Merged
MoonsuKang merged 3 commits intodevelopfrom
refactor/#276-write-diary-refactoring
Jun 8, 2025
Merged

[REFACTOR/#276] 일기작성 뒤로가기 수정 및 삭제 바텀시트 UI 수정을 진행합니다.#277
MoonsuKang merged 3 commits intodevelopfrom
refactor/#276-write-diary-refactoring

Conversation

@MoonsuKang
Copy link
Contributor

@MoonsuKang MoonsuKang commented Jun 7, 2025

📌 ISSUE

closed #276

📄 Work Description

  • 뒤로가기 버튼 클릭 시, 일기 내용에 변경이 없을 경우 바로 이전 화면으로 이동하도록 로직 수정
    • hasChangedFromInitial() 함수 내부에서 공백만 있는 입력은 동일한 것으로 간주하도록 트리밍 처리.
  • Amplitude 트래킹은 뒤로가기 클릭 시 항상 기록되도록 변경
  • 바텀시트 Spacer 제거

✨ PR Point

술먹으러 가야지~

📸 ScreenShot/Video

Summary by CodeRabbit

  • Bug Fixes

    • Improved detection of diary content changes by ignoring whitespace differences.
    • Adjusted exit confirmation logic to ensure event tracking occurs before navigation decisions.
  • Refactor

    • Removed unnecessary spacing at the bottom of the delete diary confirmation dialog for a cleaner appearance.

@MoonsuKang MoonsuKang requested a review from SYAAINN June 7, 2025 09:14
@MoonsuKang MoonsuKang self-assigned this Jun 7, 2025
@MoonsuKang MoonsuKang added ♻️ REFACTOR 코드 리팩토링(전면 수정) 🌊 문수 문수 labels Jun 7, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 7, 2025

Walkthrough

This change updates the diary writing feature by refining the logic for detecting changes in diary entries, adjusting the back navigation event sequence, and removing a fixed-height spacer from the delete confirmation bottom sheet UI. No public API or exported entity signatures were altered.

Changes

File(s) Change Summary
.../component/bottomsheet/DeleteWriteDiaryBottomSheet.kt Removed unused height import and deleted the bottom Spacer with fixed height from the UI.
.../screen/WriteDiaryScreen.kt Changed the order of event tracking and navigation in the back button logic.
.../screen/WriteDiaryViewModel.kt Enhanced hasChangedFromInitial to trim whitespace before comparing entries and handle empty state.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WriteDiaryScreen
    participant WriteDiaryViewModel
    participant Navigator

    User->>WriteDiaryScreen: Presses Back
    WriteDiaryScreen->>WriteDiaryViewModel: hasChangedFromInitial()
    WriteDiaryViewModel-->>WriteDiaryScreen: Returns change status
    WriteDiaryScreen->>WriteDiaryScreen: Track back event
    alt No changes detected
        WriteDiaryScreen->>Navigator: Navigate back
    else Changes detected
        WriteDiaryScreen->>WriteDiaryScreen: Show exit confirmation dialog
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Refactor diary writing back navigation logic (#276)
Update/delete bottom sheet UI for diary deletion (#276)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Suggested labels

🛠️ FIX

Suggested reviewers

  • SYAAINN

Poem

A bunny hopped through diary code,
Tidying logic on its road.
Trimming spaces, neat and bright,
Back it goes, events tracked right.
The bottom sheet feels light and new—
A springtime fix, from me to you! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f27d114 and 7a5931b.

📒 Files selected for processing (3)
  • app/src/main/java/com/sopt/clody/presentation/ui/writediary/component/bottomsheet/DeleteWriteDiaryBottomSheet.kt (0 hunks)
  • app/src/main/java/com/sopt/clody/presentation/ui/writediary/screen/WriteDiaryScreen.kt (1 hunks)
  • app/src/main/java/com/sopt/clody/presentation/ui/writediary/screen/WriteDiaryViewModel.kt (1 hunks)
💤 Files with no reviewable changes (1)
  • app/src/main/java/com/sopt/clody/presentation/ui/writediary/component/bottomsheet/DeleteWriteDiaryBottomSheet.kt
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (1)
app/src/main/java/com/sopt/clody/presentation/ui/writediary/screen/WriteDiaryViewModel.kt (1)

181-186: Improved change detection logic with proper whitespace handling.

The enhanced hasChangedFromInitial() function correctly addresses the PR requirements:

  • Early return for empty initial entries prevents false positives
  • Trimming both current and initial entries ensures whitespace-only changes are treated as unchanged
  • The comparison logic is more robust and user-friendly

Comment on lines 116 to 123
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)
}
},
Copy link

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.

Copy link
Contributor

@SYAAINN SYAAINN left a comment

Choose a reason for hiding this comment

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

죠습니다~

@MoonsuKang MoonsuKang merged commit f3e6d8a into develop Jun 8, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

♻️ REFACTOR 코드 리팩토링(전면 수정) 🌊 문수 문수

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] 일기작성 뒤로가기 수정 및 삭제 바텀시트 UI 수정을 진행합니다.

2 participants