Conversation
Contributor
There was a problem hiding this comment.
Code Review
이번 풀 리퀘스트는 전반적인 ViewModel의 로딩 상태 관리 로직을 개선하고 검색 기능의 태스크 관리 방식을 리팩토링하는 작업을 포함합니다. LoadingState를 활용해 로딩 지연 시간을 조정하고 대부분의 데이터 페칭 작업에 지연 로딩 모드를 적용했습니다. 또한 SearchViewModel과 TodoListViewModel에서 검색 태스크를 딕셔너리로 관리하여 취소 로직을 강화했습니다. 리뷰 피드백으로는 SearchViewModel의 .applySearchQuery와 TodoListViewModel의 .triggerSearch 액션에서 빈 문자열에 대한 검증 로직이 누락되어 불필요한 API 호출이 발생할 수 있다는 점이 지적되었습니다.
I am having trouble creating individual review comments. Click here to see my feedback.
DevLog/Presentation/ViewModel/SearchViewModel.swift (124-125)
.applySearchQuery 액션에서 검색어가 비어있는 경우에 대한 처리가 누락되었습니다. 기존 코드에서는 검색어가 비어있으면 결과를 비우고 검색을 수행하지 않았으나, 현재는 빈 문자열로 .fetch 사이드 이펙트를 실행하게 됩니다. 의도하지 않은 API 호출을 방지하기 위해 빈 문자열 체크를 추가하는 것이 좋습니다.
case .applySearchQuery(let query):
let trimmed = query.trimmingCharacters(in: .whitespacesAndNewlines)
if trimmed.isEmpty {
state.webPages = []
state.todos = []
effects = [.cancelSearch]
} else {
effects = [.fetch(trimmed)]
}DevLog/Presentation/ViewModel/TodoListViewModel.swift (374-375)
.triggerSearch 액션에서 검색어가 비어있는 경우에 대한 처리가 누락되었습니다. 기존에는 빈 문자열일 경우 검색 결과를 비우고 종료했으나, 현재는 빈 문자열로 .search 사이드 이펙트가 실행됩니다. 불필요한 호출을 막기 위해 체크 로직을 추가하는 것을 권장합니다.
case .triggerSearch(let query):
let trimmed = query.trimmingCharacters(in: .whitespacesAndNewlines)
if trimmed.isEmpty {
state.searchResults = []
return [.cancelSearch]
} else {
return [.search(trimmed)]
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 연관된 이슈
📝 작업 내용
📌 요약
🔍 상세