Merge pull request #444 from mastodon/fix-notification-admin-mod

Fix notification admin mod always display issue
This commit is contained in:
CMK 2022-05-27 00:08:58 +08:00 committed by GitHub
commit 30ddbefa92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 2 deletions

View File

@ -108,7 +108,7 @@ extension NotificationTimelineViewModel.LoadOldestState {
logger.log(level: .debug, "\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): fetch statues failed: \(error.localizedDescription)")
await self.enter(state: Fail.self)
}
} // Task
} // end Task
}
}

View File

@ -88,7 +88,6 @@ extension NotificationTimelineViewModel {
}
}
var excludeTypes: [MastodonNotificationType]? {
switch self {
case .everything: return nil

View File

@ -23,6 +23,28 @@ extension APIService {
let query = Mastodon.API.Notifications.Query(
maxID: maxID,
types: {
switch scope {
case .everything:
return [
.follow,
.followRequest,
.mention,
.reblog,
.favourite,
.poll,
.status,
]
case .mentions:
return [
.follow,
.followRequest,
.reblog,
.favourite,
.poll
]
}
}(),
excludeTypes: {
switch scope {
case .everything:

View File

@ -90,6 +90,7 @@ extension Mastodon.API.Notifications {
public let sinceID: Mastodon.Entity.Status.ID?
public let minID: Mastodon.Entity.Status.ID?
public let limit: Int?
public let types: [Mastodon.Entity.Notification.NotificationType]?
public let excludeTypes: [Mastodon.Entity.Notification.NotificationType]?
public let accountID: String?
@ -98,6 +99,7 @@ extension Mastodon.API.Notifications {
sinceID: Mastodon.Entity.Status.ID? = nil,
minID: Mastodon.Entity.Status.ID? = nil,
limit: Int? = nil,
types: [Mastodon.Entity.Notification.NotificationType]? = nil,
excludeTypes: [Mastodon.Entity.Notification.NotificationType]? = nil,
accountID: String? = nil
) {
@ -105,6 +107,7 @@ extension Mastodon.API.Notifications {
self.sinceID = sinceID
self.minID = minID
self.limit = limit
self.types = types
self.excludeTypes = excludeTypes
self.accountID = accountID
}
@ -115,6 +118,11 @@ extension Mastodon.API.Notifications {
sinceID.flatMap { items.append(URLQueryItem(name: "since_id", value: $0)) }
minID.flatMap { items.append(URLQueryItem(name: "min_id", value: $0)) }
limit.flatMap { items.append(URLQueryItem(name: "limit", value: String($0))) }
if let types = types {
types.forEach {
items.append(URLQueryItem(name: "types[]", value: $0.rawValue))
}
}
if let excludeTypes = excludeTypes {
excludeTypes.forEach {
items.append(URLQueryItem(name: "exclude_types[]", value: $0.rawValue))