Skip to content

Commit

Permalink
[수정] 검색기록 최신순으로 저장되도록 변경 (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshiningsoo authored Sep 11, 2024
1 parent 2cbf29b commit 42d6065
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-kuring/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"location" : "https://github.com/ku-ring/ios-maps",
"state" : {
"branch" : "main",
"revision" : "d0a83b7c3e6b69d77647001f17f162e1090e9489"
"revision" : "35b3e2d67e4f8b180ba0672df988110c992e6f27"
}
},
{
Expand Down
6 changes: 5 additions & 1 deletion package-kuring/Sources/Features/SearchFeatures/Search.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ public struct SearchFeature {
// 최근 검색어 추가
if !state.recents.contains(state.searchInfo.text) { // 중복체크
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.append(state.searchInfo.text)
recentSearch.remove(state.searchInfo.text)
recentSearch.add(state.searchInfo.text)
}

Expand Down
2 changes: 1 addition & 1 deletion package-kuring/Sources/UIKit/SearchUI/SearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 42d6065

Please sign in to comment.