Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[수정] 검색기록 최신순으로 저장되도록 변경 #233

Merged
merged 5 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
lgvv marked this conversation as resolved.
Show resolved Hide resolved
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