mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-04-24 04:05:16 +08:00
fetch subscription status and fix mutation (#2291)
This commit is contained in:
@@ -101,7 +101,7 @@ final class NotificationModelController {
|
||||
return
|
||||
}
|
||||
|
||||
let content = "state comments{totalCount}"
|
||||
let content = "state comments{totalCount} viewerSubscription"
|
||||
let notificationQueries: String = notifications.compactMap {
|
||||
guard let alias = $0.stateAlias else { return nil }
|
||||
return """
|
||||
@@ -124,10 +124,12 @@ final class NotificationModelController {
|
||||
let stateString = issueOrPullRequest["state"] as? String,
|
||||
let state = NotificationViewModel.State(rawValue: stateString),
|
||||
let commentsJSON = issueOrPullRequest["comments"] as? [String: Any],
|
||||
let commentCount = commentsJSON["totalCount"] as? Int {
|
||||
let commentCount = commentsJSON["totalCount"] as? Int,
|
||||
let subscription = issueOrPullRequest["viewerSubscription"] as? String {
|
||||
var newNotification = notification
|
||||
newNotification.state = state
|
||||
newNotification.comments = commentCount
|
||||
newNotification.watching = subscription != "IGNORED"
|
||||
updatedNotifications.append(newNotification)
|
||||
} else {
|
||||
updatedNotifications.append(notification)
|
||||
@@ -186,7 +188,7 @@ final class NotificationModelController {
|
||||
model.watching = !notification.watching
|
||||
cache.set(value: model)
|
||||
|
||||
githubClient.client.send(V3SubscribeThreadRequest(id: model.v3id, ignore: model.watching)) { result in
|
||||
githubClient.client.send(V3SubscribeThreadRequest(id: model.v3id, ignore: !model.watching)) { result in
|
||||
switch result {
|
||||
case .success:
|
||||
Haptic.triggerSelection()
|
||||
|
||||
@@ -16,7 +16,7 @@ public struct V3SubscribeThreadRequest: V3Request {
|
||||
public var method: HTTPMethod { return .put }
|
||||
public var parameters: [String : Any]? {
|
||||
return [
|
||||
"ignored": ignore ? "true" : "false"
|
||||
"ignored": ignore ? true : false
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user