mirror of
https://github.com/mastodon/mastodon-ios
synced 2025-04-11 22:58:02 +02:00
Replace items instead of adding them (IOS-196)
This commit is contained in:
parent
59c6d31ca4
commit
6b0fe64262
@ -28,6 +28,10 @@ extension FileManager {
|
||||
|
||||
var searchItems = (try? searchItems(forUser: newSearchItem.userID)) ?? []
|
||||
|
||||
if let index = searchItems.firstIndex(of: newSearchItem) {
|
||||
searchItems.remove(at: index)
|
||||
}
|
||||
|
||||
searchItems.append(newSearchItem)
|
||||
|
||||
let jsonEncoder = JSONEncoder()
|
||||
|
@ -5,11 +5,21 @@ import MastodonCore
|
||||
import MastodonSDK
|
||||
|
||||
extension Persistence.SearchHistory {
|
||||
struct Item: Codable {
|
||||
struct Item: Codable, Hashable, Equatable {
|
||||
let updatedAt: Date
|
||||
let userID: Mastodon.Entity.Account.ID
|
||||
|
||||
let account: Mastodon.Entity.Account?
|
||||
let hashtag: Mastodon.Entity.Tag?
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(userID)
|
||||
hasher.combine(account)
|
||||
hasher.combine(hashtag)
|
||||
}
|
||||
|
||||
public static func == (lhs: Persistence.SearchHistory.Item, rhs: Persistence.SearchHistory.Item) -> Bool {
|
||||
return lhs.account == rhs.account && lhs.hashtag == rhs.hashtag
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user