Skip to content

[Feature/#63] 루틴 등록/수정시 홈 화면 리프레시 기능 구현#64

Merged
l5x5l merged 2 commits intodevelopfrom
feature/#63-refresh_home
Jul 30, 2025
Merged

[Feature/#63] 루틴 등록/수정시 홈 화면 리프레시 기능 구현#64
l5x5l merged 2 commits intodevelopfrom
feature/#63-refresh_home

Conversation

@l5x5l
Copy link
Copy Markdown
Contributor

@l5x5l l5x5l commented Jul 30, 2025

[ PR Content ]

추천 루틴을 등록하거나 루틴을 등록/삭제했을 때 홈 화면에서 바로 리프래시하여 사용자가 갱신된 루틴 목록을 볼 수 있도록 합니다.

Related issue

Screenshot 📸

KakaoTalk_Video_2025-07-30-22-29-22.mp4

Work Description

  • 루틴 작성/루틴 수정이 성공한 경우 홈 화면 리프레시가 수행됩니다

To Reviewers 📢

  • 루틴 작성/수정 이벤트의 경우 WriteRoutineRepository 내부에서 처리하고 있는데 이에 대한 이유는 아래와 같습니다!
    • 해당 데이터가 런타임에만 저장되는 데이터이기 때문에 dataSource에 넣는게 살짝 어색하다고 느껴졌습니다
    • dataSource에 배치할 경우 data layer 내 사용을 위한 클래스를 별도로 생성해야 하는데 domain 클래스와 완전히 동일할 것으로 생각되어 불필요하다고 느껴졌습니다
    • 다만 이건 제 생각이어서 다른 의견 있으시다면 공유 부탁드립니다!
  • 영상 녹화하면서 알게 된 내용인데, 링크 수정 이후 바텀 시트와 현재 표시되는 루틴 명이 다른 부분이 있어서 추후 링크 수정 누르면 바텀 시트가 그냥 종료되로록 하는게 좋을 것 같습니다!
  • 위 내용 외 다른 궁금한 부분 있으시다면 코멘트 부탁드려요!

Summary by CodeRabbit

  • New Features
    • 루틴 등록 및 수정 시 이벤트가 발생하여, 루틴 추가 또는 수정 후 홈 화면의 주간 루틴 목록이 자동으로 새로고침됩니다.
    • 루틴 관련 이벤트를 실시간으로 감지할 수 있는 기능이 추가되었습니다.

@l5x5l l5x5l requested a review from wjdrjs00 July 30, 2025 13:54
@l5x5l l5x5l self-assigned this Jul 30, 2025
@l5x5l l5x5l added ✨ Feature 새로운 기능 구현 세환 labels Jul 30, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 30, 2025

Walkthrough

루틴 등록 및 수정 시 발생하는 이벤트를 WriteRoutineEvent로 정의하고, 이를 SharedFlow로 노출하는 구조가 도입되었습니다. 저장소, 도메인 인터페이스, 유스케이스, 그리고 뷰모델이 해당 이벤트를 관찰 및 활용하도록 확장되어 홈 화면이 루틴 변경 시 자동으로 갱신됩니다.

Changes

Cohort / File(s) Change Summary
WriteRoutineEvent 도메인 모델 추가
domain/.../writeroutine/model/WriteRoutineEvent.kt
루틴 추가/수정 이벤트를 나타내는 sealed interface 및 구현체(AddRoutine, EditRoutine) 신설
Repository 인터페이스 및 구현 확장
domain/.../writeroutine/repository/WriteRoutineRepository.kt,
data/.../writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt
루틴 이벤트를 emit/관찰할 수 있도록 getWriteRoutineEventFlow() 메서드 추가 및 SharedFlow 구현
이벤트 Flow 유스케이스 추가
domain/.../writeroutine/usecase/GetWriteRoutineEventFlowUseCase.kt
저장소의 이벤트 Flow를 반환하는 유스케이스 클래스 신설
HomeViewModel 이벤트 관찰 및 리프레시
presentation/.../home/HomeViewModel.kt
루틴 이벤트 관찰 후 홈 화면 루틴 목록 자동 갱신 로직 추가 및 의존성 주입

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant ViewModel as HomeViewModel
    participant UseCase as GetWriteRoutineEventFlowUseCase
    participant Repo as WriteRoutineRepositoryImpl
    participant DataSource

    User->>Repo: registerRoutine() / editRoutine()
    Repo->>DataSource: 요청 위임
    DataSource-->>Repo: 결과 반환
    alt 성공 시
        Repo->>Repo: _writeRoutineEventFlow.emit(AddRoutine/EditRoutine)
    end
    ViewModel->>UseCase: getWriteRoutineEventFlowUseCase()
    UseCase->>Repo: getWriteRoutineEventFlow()
    Repo-->>UseCase: SharedFlow<WriteRoutineEvent>
    UseCase-->>ViewModel: SharedFlow<WriteRoutineEvent>
    ViewModel->>ViewModel: 이벤트 수신 시 fetchWeeklyRoutines() 호출
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

Objective (Issue No.) Addressed Explanation
루틴 변경 내용 관찰 flow 구현 (#63)

Assessment against linked issues: Out-of-scope changes

(해당 변경사항 중 요구사항과 무관한 기능적 코드 변경은 발견되지 않았습니다.)

Suggested reviewers

  • wjdrjs00

Poem

🐇
루틴이 바뀌면 홈이 반짝,
이벤트 타고 새로 고침 착착!
Flow를 타고 소식이 와요,
토끼도 신나서 귀를 세워요.
코드가 춤추는 리프레시의 밤,
비트나길 홈이 더 반짝!

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/#63-refresh_home

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 generate unit tests to generate unit tests for 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
Copy Markdown

@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: 0

🧹 Nitpick comments (2)
presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt (1)

234-240: 에러 핸들링 추가를 고려해보세요

이벤트 플로우 수집 로직은 올바르게 구현되었지만, 플로우에서 예외가 발생할 경우에 대한 처리를 추가하는 것이 좋겠습니다.

다음과 같이 에러 핸들링을 추가할 수 있습니다:

 private fun observeWriteRoutineEvent() {
     viewModelScope.launch {
-        getWriteRoutineEventFlowUseCase().collect {
-            fetchWeeklyRoutines(container.stateFlow.value.currentWeeks)
+        try {
+            getWriteRoutineEventFlowUseCase().collect {
+                fetchWeeklyRoutines(container.stateFlow.value.currentWeeks)
+            }
+        } catch (e: Exception) {
+            Log.e("HomeViewModel", "루틴 이벤트 관찰 실패: ${e.message}")
         }
     }
 }
data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt (1)

58-59: SharedFlow 설정 검토를 고려해보세요

현재 기본 설정으로 MutableSharedFlow를 사용하고 있는데, 구독자가 없을 때 이벤트가 손실될 수 있습니다. 필요에 따라 replay나 extraBufferCapacity 설정을 고려해보세요.

이벤트 손실을 방지하려면 다음과 같이 설정할 수 있습니다:

-private val _writeRoutineEventFlow = MutableSharedFlow<WriteRoutineEvent>()
+private val _writeRoutineEventFlow = MutableSharedFlow<WriteRoutineEvent>(
+    replay = 1,
+    extraBufferCapacity = 64
+)

다만 현재 HomeViewModel에서 즉시 구독을 시작하므로 기본 설정으로도 충분할 수 있습니다.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ea90e62 and 5bdd146.

📒 Files selected for processing (5)
  • data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt (3 hunks)
  • domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/model/WriteRoutineEvent.kt (1 hunks)
  • domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/repository/WriteRoutineRepository.kt (2 hunks)
  • domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/GetWriteRoutineEventFlowUseCase.kt (1 hunks)
  • presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (9)
domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/model/WriteRoutineEvent.kt (1)

3-6: 이벤트 모델링이 잘 설계되었습니다

sealed interface를 사용한 이벤트 타입 정의가 적절하며, AddRoutine은 data object로, EditRoutine은 routineId를 포함한 data class로 구현한 것이 타입 안전성과 확장성을 보장합니다.

domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/repository/WriteRoutineRepository.kt (2)

6-7: 필요한 임포트가 올바르게 추가되었습니다

WriteRoutineEvent와 Flow 관련 임포트가 적절히 추가되어 새로운 기능을 지원합니다.


25-25: 반응형 프로그래밍 패턴을 잘 적용했습니다

suspend 함수로 Flow를 반환하는 설계가 코루틴과 잘 어우러지며, 기존 인터페이스 계약을 깨뜨리지 않고 확장되었습니다.

domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/GetWriteRoutineEventFlowUseCase.kt (1)

8-12: 깔끔한 유스케이스 구현입니다

의존성 주입과 operator fun invoke()를 사용한 함수형 스타일이 적절하며, 도메인 계층의 추상화 역할을 잘 수행합니다.

presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt (2)

47-47: 의존성 주입이 올바르게 추가되었습니다

GetWriteRoutineEventFlowUseCase가 적절히 주입되어 이벤트 플로우를 관찰할 수 있습니다.


57-57: 초기화 시점이 적절합니다

init 블록에서 observeWriteRoutineEvent()를 호출하여 ViewModel 생성과 동시에 이벤트 관찰을 시작합니다.

data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt (3)

10-14: 필요한 임포트가 올바르게 추가되었습니다

WriteRoutineEvent와 Flow 관련 임포트들이 새로운 기능 구현에 필요한 모든 요소를 포함합니다.


27-31: 성공 시에만 이벤트를 발생시키는 로직이 적절합니다

also 블록을 사용하여 registerRoutine 성공 후에만 AddRoutine 이벤트를 발생시키는 것이 올바른 접근입니다.


51-55: 루틴ID를 포함한 이벤트 발생이 적절합니다

editRoutine 성공 후 routineId를 포함한 EditRoutine 이벤트를 발생시켜 어떤 루틴이 수정되었는지 명확히 전달합니다.

Copy link
Copy Markdown
Member

@wjdrjs00 wjdrjs00 left a comment

Choose a reason for hiding this comment

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

등록, 수정 시 이벤트를 방출하고 수집해서 리프레시하는 방법이군요??! 야무집니다요!
현재로써는 저도 이걸 굳이 data레이어 까지 올려야 하는 필요성을 못 느껴서 리포지토리에서 처리하는 방식도 문제없을듯 합니다!!
고생하셨습니다! 어푸푸

@l5x5l l5x5l merged commit 4244167 into develop Jul 30, 2025
2 checks passed
@l5x5l l5x5l deleted the feature/#63-refresh_home branch July 30, 2025 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 새로운 기능 구현 세환

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] 루틴 등록/수정시 홈 화면 리프레시 기능 구현

2 participants