Skip to content

[#203] TodoEditorView에서 수정 시 최초 값과 다를 때만 서버에 업데이트될 수 있도록 버튼을 제한한다#205

Merged
opficdev merged 2 commits intodevelopfrom
feat/#203-TodoEditorView-Submit
Mar 6, 2026
Merged

[#203] TodoEditorView에서 수정 시 최초 값과 다를 때만 서버에 업데이트될 수 있도록 버튼을 제한한다#205
opficdev merged 2 commits intodevelopfrom
feat/#203-TodoEditorView-Submit

Conversation

@opficdev
Copy link
Copy Markdown
Owner

@opficdev opficdev commented Mar 6, 2026

@opficdev opficdev self-assigned this Mar 6, 2026
@gemini-code-assist
Copy link
Copy Markdown
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!

이 풀 리퀘스트는 Todo 편집 화면에서 사용자가 내용을 수정했을 때, 최초 값과 다를 경우에만 서버에 업데이트 요청을 보낼 수 있도록 제출 버튼의 활성화 로직을 개선합니다. 이를 통해 불필요한 서버 호출을 줄이고 사용자 경험을 향상시킵니다.

Highlights

  • 불필요한 서버 업데이트 방지 로직 추가: TodoEditorViewModel에 Draft 구조체를 도입하여 Todo 항목의 최초 상태를 저장하고, 현재 편집 중인 상태와 비교하여 변경 사항이 있을 때만 서버 업데이트가 가능하도록 hasChangesisReadyToSubmit 계산 속성을 추가했습니다.
  • 제출 버튼 활성화 조건 개선: TodoEditorView에서 제출 버튼(ToolbarTrailingButton)의 활성화 조건을 viewModel.state.isValidToSave에서 viewModel.isReadyToSubmit으로 변경하여, 유효성 검사 통과와 더불어 실제 변경 사항이 있을 때만 버튼이 활성화되도록 했습니다.
  • 코드 리팩토링 및 가독성 향상: TodoEditorViewModel의 upsertTodo() 함수를 makeTodo()로 이름을 변경하여 Todo 객체를 생성하는 역할을 명확히 했으며, TodoEditorView의 제출 로직을 submit()이라는 private 함수로 분리하여 코드의 응집도를 높였습니다.
Changelog
  • DevLog/Presentation/ViewModel/TodoEditorViewModel.swift
    • Todo의 최초 상태를 저장하기 위한 Draft private 구조체 추가
    • 최초 Todo 상태를 저장하는 originalDraft 속성 추가
    • 현재 상태와 originalDraft를 비교하여 변경 여부를 확인하는 hasChanges 계산 속성 추가
    • 저장 유효성과 변경 여부를 모두 확인하여 제출 가능 상태를 나타내는 isReadyToSubmit 계산 속성 추가
    • 새로운 Todo 생성 및 기존 Todo 편집 생성자에서 originalDraft 초기화 로직 추가
    • upsertTodo() 함수를 makeTodo()로 이름 변경
  • DevLog/UI/Home/TodoEditorView.swift
    • 제출 버튼의 disabled 조건에 viewModel.isReadyToSubmit 적용
    • 제출 로직을 submit() private 함수로 분리하여 호출
    • 이전의 toolBar @ToolbarContentBuilder를 제거하고 인라인으로 ToolbarLeadingButtonToolbarTrailingButton 사용
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
Copy Markdown
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은 TodoEditorView에서 할 일을 수정할 때, 내용이 실제로 변경되었을 경우에만 '저장' 버튼이 활성화되도록 하는 기능을 구현했습니다. 이를 위해 Todo의 초기 상태를 저장하는 Draft 구조체를 도입하고, 현재 상태와 비교하여 변경 여부를 판단하는 로직을 TodoEditorViewModel에 추가했습니다. 이 로직은 TodoEditorView에서 버튼의 활성화 상태를 제어하는 데 사용됩니다. 전반적으로 잘 구현되었으며, 불필요한 서버 업데이트를 방지하여 사용자 경험을 개선하는 좋은 변경입니다. 코드 개선을 위한 한 가지 작은 제안이 있습니다.

Comment on lines +166 to 171
private func submit() {
if !viewModel.isReadyToSubmit { return }
let todo = viewModel.makeTodo()
onSubmit?(todo)
dismiss()
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

submit() 함수는 viewModel.isReadyToSubmittrue일 때만 활성화되는 버튼에 의해 호출됩니다. 따라서 함수 내에서 !viewModel.isReadyToSubmit을 다시 확인하는 것은 중복입니다. 이 중복 확인을 제거하여 코드를 더 간결하게 만들 수 있습니다.

    private func submit() {
        let todo = viewModel.makeTodo()
        onSubmit?(todo)
        dismiss()
    }

@opficdev opficdev merged commit b23d9dd into develop Mar 6, 2026
1 check passed
@opficdev opficdev deleted the feat/#203-TodoEditorView-Submit branch March 6, 2026 12:08
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.

TodoEditorView에서 수정 시 최초 값과 다를 때만 서버에 업데이트될 수 있도록 버튼을 제한한다

1 participant