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 }) {
|
for followed in followed where !saved.contains(where: { $0.name == followed.name }) {
|
||||||
items.append(.savedHashtag(Hashtag(name: followed.name, url: followed.url)))
|
items.append(.savedHashtag(Hashtag(name: followed.name, url: followed.url)))
|
||||||
}
|
}
|
||||||
|
items = items.uniques()
|
||||||
items.sort(using: SemiCaseSensitiveComparator.keyPath(\.label))
|
items.sort(using: SemiCaseSensitiveComparator.keyPath(\.label))
|
||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
@ -215,7 +216,7 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
|
||||||
let req = SavedInstance.fetchRequest(account: mastodonController.accountInfo!)
|
let req = SavedInstance.fetchRequest(account: mastodonController.accountInfo!)
|
||||||
req.sortDescriptors = [NSSortDescriptor(key: "url.host", ascending: true)]
|
req.sortDescriptors = [NSSortDescriptor(key: "url.host", ascending: true)]
|
||||||
do {
|
do {
|
||||||
return try mastodonController.persistentContainer.viewContext.fetch(req)
|
return try mastodonController.persistentContainer.viewContext.fetch(req).uniques()
|
||||||
} catch {
|
} catch {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,6 +240,7 @@ class MainSidebarViewController: UIViewController {
|
||||||
for followed in followed where !saved.contains(where: { $0.name == followed.name }) {
|
for followed in followed where !saved.contains(where: { $0.name == followed.name }) {
|
||||||
items.append(.savedHashtag(Hashtag(name: followed.name, url: followed.url)))
|
items.append(.savedHashtag(Hashtag(name: followed.name, url: followed.url)))
|
||||||
}
|
}
|
||||||
|
items = items.uniques()
|
||||||
items.sort(using: SemiCaseSensitiveComparator.keyPath(\.title))
|
items.sort(using: SemiCaseSensitiveComparator.keyPath(\.title))
|
||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
@ -249,7 +250,7 @@ class MainSidebarViewController: UIViewController {
|
||||||
let req = SavedInstance.fetchRequest(account: mastodonController.accountInfo!)
|
let req = SavedInstance.fetchRequest(account: mastodonController.accountInfo!)
|
||||||
req.sortDescriptors = [NSSortDescriptor(key: "url.host", ascending: true)]
|
req.sortDescriptors = [NSSortDescriptor(key: "url.host", ascending: true)]
|
||||||
do {
|
do {
|
||||||
return try mastodonController.persistentContainer.viewContext.fetch(req)
|
return try mastodonController.persistentContainer.viewContext.fetch(req).uniques()
|
||||||
} catch {
|
} catch {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue