Skip to content

[#277] HomeView의 액션을 정리한다#280

Merged
opficdev merged 1 commit intodevelopfrom
refactor/#277-HomeView-Action
Mar 16, 2026
Merged

[#277] HomeView의 액션을 정리한다#280
opficdev merged 1 commit intodevelopfrom
refactor/#277-HomeView-Action

Conversation

@opficdev
Copy link
Owner

@opficdev opficdev self-assigned this Mar 16, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 풀 리퀘스트는 HomeViewModel의 액션과 상태 관리를 리팩토링하여 코드의 응집도를 높이고 중복을 줄이는 것을 목표로 합니다. UI 프레젠테이션 및 로딩 상태를 처리하기 위한 일반화된 setPresentationsetLoading 액션과 헬퍼 메서드를 도입하여, 기존의 개별적인 상태 설정 액션들을 대체했습니다. 이를 통해 뷰 모델의 Action 열거형이 간소화되고, 관련 로직이 더 명확하게 분리되었습니다.

Highlights

  • 액션 및 상태 관리 통합: UI 프레젠테이션 및 로딩 상태 관리를 위한 setPresentationsetLoading이라는 두 가지 새로운 통합 액션과 헬퍼 메서드를 도입했습니다.
  • 열거형 도입: UI 프레젠테이션 컨텍스트를 정의하는 Presentation 열거형과 로딩 컨텍스트를 정의하는 LoadingTarget 열거형을 새로 추가했습니다.
  • ViewModel 액션 간소화: HomeViewModelAction 열거형에서 여러 개별적인 setShow...set...Loading 액션들을 제거하고, 새로운 통합 액션들로 대체하여 액션 목록을 간소화했습니다.
  • 뷰 업데이트: HomeView에서 다양한 UI 시트 및 전체 화면 커버를 관리하기 위해 기존의 개별 액션 호출 대신 새로운 setPresentation 액션을 사용하도록 업데이트했습니다.
  • 상태 변수 제거: HomeViewModel.State에서 searchTextisSearching 상태 변수를 제거했습니다.
Changelog
  • DevLog/Presentation/ViewModel/HomeViewModel.swift
    • State에서 searchTextisSearching 변수가 제거되었습니다.
    • Action 열거형에 setPresentationsetLoading 케이스가 추가되고, 여러 개별적인 setShow...set...Loading 케이스가 제거되었습니다.
    • PresentationLoadingTarget 열거형이 새로 정의되었습니다.
    • reduceByUser 메서드가 제거되고, reduceByViewreduceByRun 메서드가 업데이트된 액션 처리 로직을 반영하도록 수정되었습니다.
    • setPresentationsetLoading 헬퍼 메서드가 추가되어 UI 프레젠테이션 및 로딩 상태 관리를 중앙 집중화했습니다.
  • DevLog/UI/Home/HomeView.swift
    • HomeViewModelsetReorderTodo, setShowTodoEditor, setShowSearchView, setShowContentPicker 액션 호출이 새로운 setPresentation 액션 호출로 변경되었습니다.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

이 PR은 HomeView의 Action을 보다 체계적으로 정리하여 코드의 가독성과 유지보수성을 향상시키는 좋은 리팩토링입니다. setPresentation, setLoading과 같은 새로운 Action을 도입하여 관련된 상태 변경 로직을 통합한 점이 인상적입니다. 전반적으로 훌륭한 개선이지만, run(_ effect:) 메서드 내에 중복된 코드가 있어 이를 개선하기 위한 제안을 남겼습니다.

Comment on lines 135 to 165
case .addTodo(let todo):
Task {
do {
send(.setAppending(true))
defer { send(.setLoading(.overlay, false)) }
send(.setLoading(.overlay, true))
try await upsertTodoUseCase.execute(todo)
let page = try await fetchRecentTodos()
let items = page.items
.filter { $0.createdAt != $0.updatedAt }
.prefix(5)
.map { RecentTodoItem(from: $0) }
send(.fetchRecentTodos(items))
send(.updateRecentTodos(items))
} catch {
send(.setAlert(isPresented: true, type: .error))
}
}
case .fetchRecentTodos:
Task {
do {
defer { send(.setRecentTodosLoading(false)) }
send(.setRecentTodosLoading(true))
defer { send(.setLoading(.recentTodos, false)) }
send(.setLoading(.recentTodos, true))
let page = try await fetchRecentTodos()
let items = page.items
.filter { $0.createdAt != $0.updatedAt }
.prefix(5)
.map { RecentTodoItem(from: $0) }
send(.fetchRecentTodos(items))
send(.updateRecentTodos(items))
} catch {
send(.setAlert(isPresented: true, type: .error))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

.addTodo.fetchRecentTodos 사이드 이펙트 처리 로직에 중복 코드가 있습니다. 최근 Todo 목록을 가져와서 상태를 업데이트하는 로직을 별도의 private 메서드로 추출하여 중복을 제거하고 코드 유지보수성을 높이는 것을 제안합니다.

예를 들어, 다음과 같은 private helper 메서드를 추가할 수 있습니다.

private func refreshRecentTodos() async throws {
    let page = try await fetchRecentTodos()
    let items = page.items
        .filter { $0.createdAt != $0.updatedAt }
        .prefix(5)
        .map { RecentTodoItem(from: $0) }
    send(.updateRecentTodos(items))
}

그리고 이 메서드를 사용하여 .addTodo.fetchRecentTodos 케이스를 리팩토링할 수 있습니다.

        case .addTodo(let todo):
            Task {
                do {
                    defer { send(.setLoading(.overlay, false)) }
                    send(.setLoading(.overlay, true))
                    try await upsertTodoUseCase.execute(todo)
                    try await refreshRecentTodos()
                } catch {
                    send(.setAlert(isPresented: true, type: .error))
                }
            }
        case .fetchRecentTodos:
            Task {
                do {
                    defer { send(.setLoading(.recentTodos, false)) }
                    send(.setLoading(.recentTodos, true))
                    try await refreshRecentTodos()
                } catch {
                    send(.setAlert(isPresented: true, type: .error))
                }
            }

@opficdev opficdev merged commit e97c12a into develop Mar 16, 2026
2 checks passed
@opficdev opficdev deleted the refactor/#277-HomeView-Action branch March 16, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HomeView의 액션을 정리한다

1 participant