Skip to content

Commit

Permalink
[Modify] PostSearch 에러 첫번째 문제 해결 #173
Browse files Browse the repository at this point in the history
  • Loading branch information
bdrsky2010 committed Apr 12, 2024
1 parent f9a5147 commit 8e33a6d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 2 additions & 3 deletions JUDA_iOS/JUDA/View/Posts/PostsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ struct PostsView: View {
// 상단 서치바
SearchBar(inputText: $postSearchText, isFocused: $isFocused) {
Task(priority: .high) {
postViewModel.clearSearchedPosts()
await postViewModel.getSearchedPosts(from: postSearchText)
}
}
// 서치바 Text가 없을 때, 게시글 검색 결과 비워주기
.onChange(of: postSearchText) { _ in
if postSearchText == "" {
postViewModel.searchPostsByUserName = []
postViewModel.searchPostsByDrinkTag = []
postViewModel.searchPostsByFoodTag = []
postViewModel.clearSearchedPosts()
}
}
// MARK: 검색어 입력 중
Expand Down
7 changes: 7 additions & 0 deletions JUDA_iOS/JUDA/ViewModel/Posts/PostViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,13 @@ extension PostViewModel {
searchPostsByFoodTag = result
}
}

// '검색된 게시글' 배열 요소 전체 삭제
func clearSearchedPosts() {
searchPostsByUserName = []
searchPostsByDrinkTag = []
searchPostsByFoodTag = []
}
}

// MARK: - Report Upload
Expand Down

0 comments on commit 8e33a6d

Please sign in to comment.