mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-05-30 12:15:26 +08:00
PR thread comments working
This commit is contained in:
@@ -44,6 +44,7 @@ extension IssueOrPullRequestQuery.Data.Repository.IssueOrPullRequest.AsPullReque
|
||||
|
||||
for node in timeline.nodes ?? [] {
|
||||
guard let node = node else { continue }
|
||||
|
||||
if let comment = node.asIssueComment {
|
||||
if let model = createCommentModel(
|
||||
id: comment.fragments.nodeFields.id,
|
||||
@@ -123,10 +124,29 @@ extension IssueOrPullRequestQuery.Data.Repository.IssueOrPullRequest.AsPullReque
|
||||
pullRequest: false
|
||||
)
|
||||
results.append(model)
|
||||
} else if let thread = node.asPullRequestReviewThread {
|
||||
results += commentModels(thread: thread, width: width)
|
||||
}
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
private func commentModels(thread: Timeline.Node.AsPullRequestReviewThread, width: CGFloat) -> [ListDiffable] {
|
||||
var results = [ListDiffable]()
|
||||
for node in thread.comments.nodes ?? [] {
|
||||
guard let fragments = node?.fragments else { continue }
|
||||
|
||||
if let model = createCommentModel(
|
||||
id: fragments.nodeFields.id,
|
||||
commentFields: fragments.commentFields,
|
||||
reactionFields: fragments.reactionFields,
|
||||
width: width
|
||||
) {
|
||||
results.append(model)
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>388</string>
|
||||
<string>392</string>
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
<array>
|
||||
<string>org-appextension-feature-password-management</string>
|
||||
|
||||
@@ -317,8 +317,9 @@ public final class IssueOrPullRequestQuery: GraphQLQuery {
|
||||
" __typename" +
|
||||
" nodes {" +
|
||||
" __typename" +
|
||||
" ...reactionFields" +
|
||||
" ...nodeFields" +
|
||||
" ...commentFields" +
|
||||
" position" +
|
||||
" path" +
|
||||
" diffHunk" +
|
||||
" }" +
|
||||
@@ -326,6 +327,7 @@ public final class IssueOrPullRequestQuery: GraphQLQuery {
|
||||
" }" +
|
||||
" ... on PullRequestReview {" +
|
||||
" __typename" +
|
||||
" ...nodeFields" +
|
||||
" ...commentFields" +
|
||||
" state" +
|
||||
" submittedAt" +
|
||||
@@ -957,11 +959,13 @@ public final class IssueOrPullRequestQuery: GraphQLQuery {
|
||||
state = try reader.value(for: Field(responseName: "state"))
|
||||
submittedAt = try reader.optionalValue(for: Field(responseName: "submittedAt"))
|
||||
|
||||
let nodeFields = try NodeFields(reader: reader)
|
||||
let commentFields = try CommentFields(reader: reader)
|
||||
fragments = Fragments(commentFields: commentFields)
|
||||
fragments = Fragments(nodeFields: nodeFields, commentFields: commentFields)
|
||||
}
|
||||
|
||||
public struct Fragments {
|
||||
public let nodeFields: NodeFields
|
||||
public let commentFields: CommentFields
|
||||
}
|
||||
|
||||
@@ -1340,8 +1344,6 @@ public final class IssueOrPullRequestQuery: GraphQLQuery {
|
||||
|
||||
public struct Node: GraphQLMappable {
|
||||
public let __typename: String
|
||||
/// The line index in the diff to which the comment applies.
|
||||
public let position: Int?
|
||||
/// The path to which the comment applies.
|
||||
public let path: String
|
||||
/// The diff hunk to which the comment applies.
|
||||
@@ -1351,15 +1353,18 @@ public final class IssueOrPullRequestQuery: GraphQLQuery {
|
||||
|
||||
public init(reader: GraphQLResultReader) throws {
|
||||
__typename = try reader.value(for: Field(responseName: "__typename"))
|
||||
position = try reader.optionalValue(for: Field(responseName: "position"))
|
||||
path = try reader.value(for: Field(responseName: "path"))
|
||||
diffHunk = try reader.value(for: Field(responseName: "diffHunk"))
|
||||
|
||||
let reactionFields = try ReactionFields(reader: reader)
|
||||
let nodeFields = try NodeFields(reader: reader)
|
||||
let commentFields = try CommentFields(reader: reader)
|
||||
fragments = Fragments(commentFields: commentFields)
|
||||
fragments = Fragments(reactionFields: reactionFields, nodeFields: nodeFields, commentFields: commentFields)
|
||||
}
|
||||
|
||||
public struct Fragments {
|
||||
public let reactionFields: ReactionFields
|
||||
public let nodeFields: NodeFields
|
||||
public let commentFields: CommentFields
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,14 +173,16 @@ query IssueOrPullRequest($owner: String!, $repo: String!, $number: Int!, $page_s
|
||||
... on PullRequestReviewThread {
|
||||
comments(first:$page_size) {
|
||||
nodes {
|
||||
...reactionFields
|
||||
...nodeFields
|
||||
...commentFields
|
||||
position
|
||||
path
|
||||
diffHunk
|
||||
}
|
||||
}
|
||||
}
|
||||
... on PullRequestReview {
|
||||
...nodeFields
|
||||
...commentFields
|
||||
state
|
||||
submittedAt
|
||||
|
||||
Reference in New Issue
Block a user