fix: app may crash due to old version insert duplicate entities issue
This commit is contained in:
parent
fb6a8a8f93
commit
5f64e5e083
|
@ -38,9 +38,13 @@ final class SearchHistoryViewModel {
|
||||||
for objectID in objectIDs {
|
for objectID in objectIDs {
|
||||||
guard let searchHistory = try? managedObjectContext.existingObject(with: objectID) as? SearchHistory else { continue }
|
guard let searchHistory = try? managedObjectContext.existingObject(with: objectID) as? SearchHistory else { continue }
|
||||||
if let account = searchHistory.account {
|
if let account = searchHistory.account {
|
||||||
items.append(.account(objectID: account.objectID))
|
let item: SearchHistoryItem = .account(objectID: account.objectID)
|
||||||
|
guard !items.contains(item) else { continue }
|
||||||
|
items.append(item)
|
||||||
} else if let hashtag = searchHistory.hashtag {
|
} else if let hashtag = searchHistory.hashtag {
|
||||||
items.append(.hashtag(objectID: hashtag.objectID))
|
let item: SearchHistoryItem = .hashtag(objectID: hashtag.objectID)
|
||||||
|
guard !items.contains(item) else { continue }
|
||||||
|
items.append(item)
|
||||||
} else {
|
} else {
|
||||||
// TODO: status
|
// TODO: status
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue