Remove deleted statuses on notifications screen
This commit is contained in:
parent
37442bcb48
commit
80645a089c
|
@ -120,6 +120,8 @@ class NotificationsCollectionViewController: UIViewController, TimelineLikeColle
|
||||||
filterer.filtersChanged = { [unowned self] actionsChanged in
|
filterer.filtersChanged = { [unowned self] actionsChanged in
|
||||||
self.reapplyFilters(actionsChanged: actionsChanged)
|
self.reapplyFilters(actionsChanged: actionsChanged)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||||
|
@ -253,6 +255,24 @@ class NotificationsCollectionViewController: UIViewController, TimelineLikeColle
|
||||||
dataSource.apply(snapshot)
|
dataSource.apply(snapshot)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc private func handleStatusDeleted(_ notification: Foundation.Notification) {
|
||||||
|
guard let userInfo = notification.userInfo,
|
||||||
|
let accountID = mastodonController.accountInfo?.id,
|
||||||
|
userInfo["accountID"] as? String == accountID,
|
||||||
|
let statusIDs = userInfo["statusIDs"] as? [String] else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var snapshot = dataSource.snapshot()
|
||||||
|
let items = snapshot.itemIdentifiers(inSection: .notifications)
|
||||||
|
let toDelete = statusIDs.flatMap { id in
|
||||||
|
items.lazy.filter { $0.group?.notifications.first?.status?.id == id }
|
||||||
|
}
|
||||||
|
if !toDelete.isEmpty {
|
||||||
|
snapshot.deleteItems(toDelete)
|
||||||
|
dataSource.apply(snapshot, animatingDifferences: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func dismissNotificationsInGroup(at indexPath: IndexPath) async {
|
private func dismissNotificationsInGroup(at indexPath: IndexPath) async {
|
||||||
guard case .group(let group, let collapseState, let filterState) = dataSource.itemIdentifier(for: indexPath) else {
|
guard case .group(let group, let collapseState, let filterState) = dataSource.itemIdentifier(for: indexPath) else {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue