Fix unknown notifications appearing in the Mentions tab

This commit is contained in:
Shadowfacts 2022-12-18 11:32:08 -05:00
parent 8b718ce50b
commit e0d97cd2a8
2 changed files with 7 additions and 7 deletions

View File

@ -298,9 +298,9 @@ public class Client {
} }
// MARK: - Notifications // MARK: - Notifications
public static func getNotifications(excludeTypes: [Notification.Kind], range: RequestRange = .default) -> Request<[Notification]> { public static func getNotifications(allowedTypes: [Notification.Kind], range: RequestRange = .default) -> Request<[Notification]> {
var request = Request<[Notification]>(method: .get, path: "/api/v1/notifications", queryParameters: var request = Request<[Notification]>(method: .get, path: "/api/v1/notifications", queryParameters:
"exclude_types" => excludeTypes.map { $0.rawValue } "types" => allowedTypes.map { $0.rawValue }
) )
request.range = range request.range = range
return request return request

View File

@ -22,14 +22,14 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
weak var mastodonController: MastodonController! weak var mastodonController: MastodonController!
private let excludedTypes: [Pachyderm.Notification.Kind] private let allowedTypes: [Pachyderm.Notification.Kind]
private let groupTypes = [Pachyderm.Notification.Kind.favourite, .reblog, .follow] private let groupTypes = [Pachyderm.Notification.Kind.favourite, .reblog, .follow]
private var newer: RequestRange? private var newer: RequestRange?
private var older: RequestRange? private var older: RequestRange?
init(allowedTypes: [Pachyderm.Notification.Kind], mastodonController: MastodonController) { init(allowedTypes: [Pachyderm.Notification.Kind], mastodonController: MastodonController) {
self.excludedTypes = Array(Set(Pachyderm.Notification.Kind.allCases).subtracting(allowedTypes)) self.allowedTypes = allowedTypes
self.mastodonController = mastodonController self.mastodonController = mastodonController
super.init() super.init()
@ -140,7 +140,7 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
} }
override func loadInitialItems(completion: @escaping (LoadResult) -> Void) { override func loadInitialItems(completion: @escaping (LoadResult) -> Void) {
let request = Client.getNotifications(excludeTypes: excludedTypes) let request = Client.getNotifications(allowedTypes: allowedTypes)
mastodonController.run(request) { (response) in mastodonController.run(request) { (response) in
switch response { switch response {
case let .failure(error): case let .failure(error):
@ -171,7 +171,7 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
return return
} }
let request = Client.getNotifications(excludeTypes: excludedTypes, range: older) let request = Client.getNotifications(allowedTypes: allowedTypes, range: older)
mastodonController.run(request) { (response) in mastodonController.run(request) { (response) in
switch response { switch response {
case let .failure(error): case let .failure(error):
@ -203,7 +203,7 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
return return
} }
let request = Client.getNotifications(excludeTypes: excludedTypes, range: newer) let request = Client.getNotifications(allowedTypes: allowedTypes, range: newer)
mastodonController.run(request) { (response) in mastodonController.run(request) { (response) in
switch response { switch response {
case let .failure(error): case let .failure(error):