Merge commit '30ddbefa92ecdf11815d6f4f72dd07d291df8994' into fix-badge-color

This commit is contained in:
CMK 2022-05-27 00:10:05 +08:00
commit 4c0e9c6304
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))