diff --git a/Mastodon/Scene/Notification/Notification Filtering/Policy/NotificationPolicyViewController.swift b/Mastodon/Scene/Notification/Notification Filtering/Policy/NotificationPolicyViewController.swift index b64fdb9d8..3cfde4b6c 100644 --- a/Mastodon/Scene/Notification/Notification Filtering/Policy/NotificationPolicyViewController.swift +++ b/Mastodon/Scene/Notification/Notification Filtering/Policy/NotificationPolicyViewController.swift @@ -156,7 +156,7 @@ class NotificationPolicyViewController: UIViewController { filterPrivateMentions: viewModel.privateMentions ) - + NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil) } catch { //TODO: Error Handling } diff --git a/Mastodon/Scene/Notification/Notification Filtering/Requests/NotificationRequestsTableViewController.swift b/Mastodon/Scene/Notification/Notification Filtering/Requests/NotificationRequestsTableViewController.swift index 275f5830d..c19c0a8a6 100644 --- a/Mastodon/Scene/Notification/Notification Filtering/Requests/NotificationRequestsTableViewController.swift +++ b/Mastodon/Scene/Notification/Notification Filtering/Requests/NotificationRequestsTableViewController.swift @@ -101,7 +101,6 @@ extension NotificationRequestsTableViewController: NotificationRequestTableViewC cell.rejectNotificationRequestButton.isUserInteractionEnabled = false cell.acceptNotificationRequestButton.isUserInteractionEnabled = false - //TODO: Send request, update cell, reload notification requests AND general notifications Task { [weak self] in guard let self else { return } do { @@ -110,6 +109,8 @@ extension NotificationRequestsTableViewController: NotificationRequestTableViewC let requests = try await context.apiService.notificationRequests(authenticationBox: authContext.mastodonAuthenticationBox).value + NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil) + if requests.count > 0 { await MainActor.run { [weak self] in @@ -154,6 +155,8 @@ extension NotificationRequestsTableViewController: NotificationRequestTableViewC let requests = try await context.apiService.notificationRequests(authenticationBox: authContext.mastodonAuthenticationBox).value + NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil) + if requests.count > 0 { await MainActor.run { [weak self] in diff --git a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift index 639a20d6f..a60f48025 100644 --- a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift +++ b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewModel.swift @@ -89,6 +89,17 @@ final class NotificationTimelineViewModel { } }) .store(in: &disposeBag) + + NotificationCenter.default.addObserver(self, selector: #selector(Self.notificationFilteringChanged(_:)), name: .notificationFilteringChanged, object: nil) + } + + //MARK: - Notifications + + @objc func notificationFilteringChanged(_ notification: Notification) { + dataController.records = [] + Task { [weak self] in + await self?.loadLatest() + } } } diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Notification.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Notification.swift index 9a8a8b0cd..9af896130 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Notification.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Notification.swift @@ -142,3 +142,7 @@ extension APIService { return response } } + +extension Notification.Name { + public static let notificationFilteringChanged = Notification.Name(rawValue: "org.joinmastodon.app.notificationFilteringsChanged") +}