Update policy after changes

This commit is contained in:
Nathan Mattes 2024-07-24 16:37:33 +02:00
parent 8d535be84a
commit 766e631217
3 changed files with 9 additions and 2 deletions

View File

@ -33,6 +33,7 @@ class AccountNotificationTimelineViewController: NotificationTimelineViewControl
guard let self else { return }
coordinator.showLoading()
self.navigationController?.popViewController(animated: true)
self.delegate?.acceptRequest(self, request: request)
coordinator.hideLoading()
},
@ -40,6 +41,7 @@ class AccountNotificationTimelineViewController: NotificationTimelineViewControl
guard let self else { return }
coordinator.showLoading()
self.navigationController?.popViewController(animated: true)
self.delegate?.dismissRequest(self, request: request)
coordinator.hideLoading()
}

View File

@ -126,6 +126,9 @@ extension NotificationTimelineViewController {
@objc private func refreshControlValueChanged(_ sender: RefreshControl) {
Task {
let policy = try? await context.apiService.notificationPolicy(authenticationBox: authContext.mastodonAuthenticationBox)
viewModel.notificationPolicy = policy?.value
await viewModel.loadLatest()
}
}

View File

@ -21,7 +21,7 @@ final class NotificationTimelineViewModel {
let context: AppContext
let authContext: AuthContext
let scope: Scope
let notificationPolicy: Mastodon.Entity.NotificationPolicy?
var notificationPolicy: Mastodon.Entity.NotificationPolicy?
let dataController: FeedDataController
@Published var isLoadingLatest = false
@Published var lastAutomaticFetchTimestamp: Date?
@ -96,8 +96,10 @@ final class NotificationTimelineViewModel {
//MARK: - Notifications
@objc func notificationFilteringChanged(_ notification: Notification) {
dataController.records = []
Task { [weak self] in
let policy = try await context.apiService.notificationPolicy(authenticationBox: authContext.mastodonAuthenticationBox)
self?.notificationPolicy = policy.value
await self?.loadLatest()
}
}