Update notifications after policy/request-change (IOS-241)

This commit is contained in:
Nathan Mattes 2024-07-23 10:28:51 +02:00
parent 48f58642ac
commit d87deffa6d
4 changed files with 20 additions and 2 deletions

View File

@ -156,7 +156,7 @@ class NotificationPolicyViewController: UIViewController {
filterPrivateMentions: viewModel.privateMentions filterPrivateMentions: viewModel.privateMentions
) )
NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil)
} catch { } catch {
//TODO: Error Handling //TODO: Error Handling
} }

View File

@ -101,7 +101,6 @@ extension NotificationRequestsTableViewController: NotificationRequestTableViewC
cell.rejectNotificationRequestButton.isUserInteractionEnabled = false cell.rejectNotificationRequestButton.isUserInteractionEnabled = false
cell.acceptNotificationRequestButton.isUserInteractionEnabled = false cell.acceptNotificationRequestButton.isUserInteractionEnabled = false
//TODO: Send request, update cell, reload notification requests AND general notifications
Task { [weak self] in Task { [weak self] in
guard let self else { return } guard let self else { return }
do { do {
@ -110,6 +109,8 @@ extension NotificationRequestsTableViewController: NotificationRequestTableViewC
let requests = try await context.apiService.notificationRequests(authenticationBox: authContext.mastodonAuthenticationBox).value let requests = try await context.apiService.notificationRequests(authenticationBox: authContext.mastodonAuthenticationBox).value
NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil)
if requests.count > 0 { if requests.count > 0 {
await MainActor.run { [weak self] in await MainActor.run { [weak self] in
@ -154,6 +155,8 @@ extension NotificationRequestsTableViewController: NotificationRequestTableViewC
let requests = try await context.apiService.notificationRequests(authenticationBox: authContext.mastodonAuthenticationBox).value let requests = try await context.apiService.notificationRequests(authenticationBox: authContext.mastodonAuthenticationBox).value
NotificationCenter.default.post(name: .notificationFilteringChanged, object: nil)
if requests.count > 0 { if requests.count > 0 {
await MainActor.run { [weak self] in await MainActor.run { [weak self] in

View File

@ -89,6 +89,17 @@ final class NotificationTimelineViewModel {
} }
}) })
.store(in: &disposeBag) .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()
}
} }
} }

View File

@ -142,3 +142,7 @@ extension APIService {
return response return response
} }
} }
extension Notification.Name {
public static let notificationFilteringChanged = Notification.Name(rawValue: "org.joinmastodon.app.notificationFilteringsChanged")
}