Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[수정] insert -> append로 수정
Browse files Browse the repository at this point in the history
sunshiningsoo committed Sep 10, 2024
1 parent 008e972 commit adffb55
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ extension RecentSearch {
public static let `default` = Self(
add: { keyword in
var keywords = Self.recentKeywords
keywords.insert(keyword, at: 0)
keywords.append(keyword)
Self.recentKeywords = keywords

}, remove: { keyword in
4 changes: 2 additions & 2 deletions package-kuring/Sources/Features/SearchFeatures/Search.swift
Original file line number Diff line number Diff line change
@@ -165,11 +165,11 @@ public struct SearchFeature {

// 최근 검색어 추가
if !state.recents.contains(state.searchInfo.text) { // 중복체크
state.recents.insert(state.searchInfo.text, at: 0)
state.recents.append(state.searchInfo.text)
recentSearch.add(state.searchInfo.text)
} else if let idx = state.recents.firstIndex(where: {$0 == state.searchInfo.text}) {
state.recents.remove(at: idx)
state.recents.insert(state.searchInfo.text, at: 0)
state.recents.append(state.searchInfo.text)
recentSearch.remove(state.searchInfo.text)
recentSearch.add(state.searchInfo.text)
}
2 changes: 1 addition & 1 deletion package-kuring/Sources/UIKit/SearchUI/SearchView.swift
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ public struct SearchView: View {
/// 최근 검색어 목록
ScrollView(.horizontal, showsIndicators: false) {
LazyHStack {
ForEach(store.recents, id: \.self) { recent in
ForEach(store.recents.reversed(), id: \.self) { recent in
HStack(alignment: .center, spacing: 6) {
Button {
store.send(.recentSearchKeywordTapped(recent))

0 comments on commit adffb55

Please sign in to comment.