diff --git a/Tusker/API/DeleteStatusService.swift b/Tusker/API/DeleteStatusService.swift index 881b9b4d..8525a769 100644 --- a/Tusker/API/DeleteStatusService.swift +++ b/Tusker/API/DeleteStatusService.swift @@ -35,8 +35,7 @@ class DeleteStatusService { reblogIDs = reblogs.map(\.id) } - NotificationCenter.default.post(name: .statusDeleted, object: nil, userInfo: [ - "accountID": mastodonController.accountInfo!.id, + NotificationCenter.default.post(name: .statusDeleted, object: mastodonController, userInfo: [ "statusIDs": [status.id] + reblogIDs, ]) } catch { diff --git a/Tusker/API/FetchStatusService.swift b/Tusker/API/FetchStatusService.swift index bf944b6d..07a1366d 100644 --- a/Tusker/API/FetchStatusService.swift +++ b/Tusker/API/FetchStatusService.swift @@ -36,11 +36,6 @@ class FetchStatusService { } private func handleStatusNotFound() { - // todo: what about when browsing on another instance? - guard let accountID = mastodonController.accountInfo?.id else { - return - } - var reblogIDs = [String]() if let cached = mastodonController.persistentContainer.status(for: statusID) { let reblogsReq = StatusMO.fetchRequest() @@ -50,8 +45,7 @@ class FetchStatusService { } } - NotificationCenter.default.post(name: .statusDeleted, object: nil, userInfo: [ - "accountID": accountID, + NotificationCenter.default.post(name: .statusDeleted, object: mastodonController, userInfo: [ "statusIDs": [statusID] + reblogIDs ]) } diff --git a/Tusker/Screens/Conversation/ConversationViewController.swift b/Tusker/Screens/Conversation/ConversationViewController.swift index 3e3a5ddc..764c9f13 100644 --- a/Tusker/Screens/Conversation/ConversationViewController.swift +++ b/Tusker/Screens/Conversation/ConversationViewController.swift @@ -112,7 +112,7 @@ class ConversationViewController: UIViewController { appearance.configureWithDefaultBackground() navigationItem.scrollEdgeAppearance = appearance - NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: mastodonController) } private func updateVisibilityBarButtonItem() { @@ -145,8 +145,6 @@ class ConversationViewController: UIViewController { @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], case .localID(let mainStatusID) = mode else { return diff --git a/Tusker/Screens/Explore/TrendingStatusesViewController.swift b/Tusker/Screens/Explore/TrendingStatusesViewController.swift index 447054ae..7a391927 100644 --- a/Tusker/Screens/Explore/TrendingStatusesViewController.swift +++ b/Tusker/Screens/Explore/TrendingStatusesViewController.swift @@ -102,7 +102,7 @@ class TrendingStatusesViewController: UIViewController, CollectionViewController override func viewDidLoad() { super.viewDidLoad() - NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: mastodonController) } override func viewWillAppear(_ animated: Bool) { @@ -146,8 +146,6 @@ class TrendingStatusesViewController: UIViewController, CollectionViewController @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 } diff --git a/Tusker/Screens/Local Predicate Statuses List/LocalPredicateStatusesViewController.swift b/Tusker/Screens/Local Predicate Statuses List/LocalPredicateStatusesViewController.swift index a28b4059..92939bf9 100644 --- a/Tusker/Screens/Local Predicate Statuses List/LocalPredicateStatusesViewController.swift +++ b/Tusker/Screens/Local Predicate Statuses List/LocalPredicateStatusesViewController.swift @@ -107,7 +107,7 @@ class LocalPredicateStatusesViewController: UIViewController, CollectionViewCont addKeyCommand(MenuController.refreshCommand(discoverabilityTitle: "Refresh \(predicateTitle)")) - NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: mastodonController) NotificationCenter.default.addObserver(self, selector: #selector(managedObjectsDidChange), name: .NSManagedObjectContextObjectsDidChange, object: mastodonController.persistentContainer.viewContext) } @@ -205,8 +205,6 @@ class LocalPredicateStatusesViewController: UIViewController, CollectionViewCont @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 } diff --git a/Tusker/Screens/Notifications/NotificationsCollectionViewController.swift b/Tusker/Screens/Notifications/NotificationsCollectionViewController.swift index 02e2ebb2..69e3a9c2 100644 --- a/Tusker/Screens/Notifications/NotificationsCollectionViewController.swift +++ b/Tusker/Screens/Notifications/NotificationsCollectionViewController.swift @@ -121,7 +121,7 @@ class NotificationsCollectionViewController: UIViewController, TimelineLikeColle self.reapplyFilters(actionsChanged: actionsChanged) } - NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: mastodonController) } private func createDataSource() -> UICollectionViewDiffableDataSource { @@ -257,8 +257,6 @@ class NotificationsCollectionViewController: UIViewController, TimelineLikeColle @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 } diff --git a/Tusker/Screens/Profile/ProfileStatusesViewController.swift b/Tusker/Screens/Profile/ProfileStatusesViewController.swift index cf85c9fa..3b0de882 100644 --- a/Tusker/Screens/Profile/ProfileStatusesViewController.swift +++ b/Tusker/Screens/Profile/ProfileStatusesViewController.swift @@ -148,7 +148,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie self.reapplyFilters(actionsChanged: actionsChanged) } - NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: mastodonController) } private func createDataSource() -> UICollectionViewDiffableDataSource { @@ -376,8 +376,6 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie @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 } diff --git a/Tusker/Screens/Search/SearchResultsViewController.swift b/Tusker/Screens/Search/SearchResultsViewController.swift index e4165f08..d587b006 100644 --- a/Tusker/Screens/Search/SearchResultsViewController.swift +++ b/Tusker/Screens/Search/SearchResultsViewController.swift @@ -120,7 +120,7 @@ class SearchResultsViewController: UIViewController, CollectionViewController { userActivity = UserActivityManager.searchActivity(query: nil, accountID: mastodonController.accountInfo!.id) - NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: mastodonController) } private func createDataSource() -> UICollectionViewDiffableDataSource { @@ -309,8 +309,6 @@ class SearchResultsViewController: UIViewController, CollectionViewController { @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 } diff --git a/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift b/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift index ea1e4523..d1e4a501 100644 --- a/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift +++ b/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift @@ -84,7 +84,7 @@ class StatusActionAccountListViewController: UIViewController { view.backgroundColor = .appBackground - NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: mastodonController) } override func viewWillAppear(_ animated: Bool) { @@ -99,8 +99,6 @@ class StatusActionAccountListViewController: UIViewController { @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 } diff --git a/Tusker/Screens/Timeline/TimelineViewController.swift b/Tusker/Screens/Timeline/TimelineViewController.swift index b822b49a..16d12fe7 100644 --- a/Tusker/Screens/Timeline/TimelineViewController.swift +++ b/Tusker/Screens/Timeline/TimelineViewController.swift @@ -162,7 +162,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro } } .store(in: &cancellables) - NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: mastodonController) if userActivity != nil { userActivityNeedsUpdate @@ -943,8 +943,6 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro @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 }