Unique saved hashtag/instance items
This may happen when migrating to iCloud, if the same hashtag is saved on multiple devices.
This commit is contained in:
parent
d4c560d7fc
commit
854d48e54e
|
@ -206,6 +206,7 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
|
|||
for followed in followed where !saved.contains(where: { $0.name == followed.name }) {
|
||||
items.append(.savedHashtag(Hashtag(name: followed.name, url: followed.url)))
|
||||
}
|
||||
items = items.uniques()
|
||||
items.sort(using: SemiCaseSensitiveComparator.keyPath(\.label))
|
||||
return items
|
||||
}
|
||||
|
@ -215,7 +216,7 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
|
|||
let req = SavedInstance.fetchRequest(account: mastodonController.accountInfo!)
|
||||
req.sortDescriptors = [NSSortDescriptor(key: "url.host", ascending: true)]
|
||||
do {
|
||||
return try mastodonController.persistentContainer.viewContext.fetch(req)
|
||||
return try mastodonController.persistentContainer.viewContext.fetch(req).uniques()
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
|
|
|
@ -240,6 +240,7 @@ class MainSidebarViewController: UIViewController {
|
|||
for followed in followed where !saved.contains(where: { $0.name == followed.name }) {
|
||||
items.append(.savedHashtag(Hashtag(name: followed.name, url: followed.url)))
|
||||
}
|
||||
items = items.uniques()
|
||||
items.sort(using: SemiCaseSensitiveComparator.keyPath(\.title))
|
||||
return items
|
||||
}
|
||||
|
@ -249,7 +250,7 @@ class MainSidebarViewController: UIViewController {
|
|||
let req = SavedInstance.fetchRequest(account: mastodonController.accountInfo!)
|
||||
req.sortDescriptors = [NSSortDescriptor(key: "url.host", ascending: true)]
|
||||
do {
|
||||
return try mastodonController.persistentContainer.viewContext.fetch(req)
|
||||
return try mastodonController.persistentContainer.viewContext.fetch(req).uniques()
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue