mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-04-23 19:50:19 +08:00
get PRs working again (needs cleanup)
This commit is contained in:
@@ -19,14 +19,27 @@ extension GithubClient {
|
||||
width: CGFloat,
|
||||
completion: @escaping ([IGListDiffable]) -> ()
|
||||
) {
|
||||
let query = IssueQuery(owner: owner, repo: repo, number: number)
|
||||
apollo.fetch(query: query) { (result, error) in
|
||||
if let issue = result?.data?.repository?.issue {
|
||||
createViewModels(issue: issue, width: width) { results in
|
||||
completion(results)
|
||||
if pullRequest {
|
||||
let query = PullRequestQuery(owner: owner, repo: repo, number: number)
|
||||
apollo.fetch(query: query) { (result, error) in
|
||||
if let pullRequest = result?.data?.repository?.pullRequest {
|
||||
createViewModels(pullRequest: pullRequest, width: width) { results in
|
||||
completion(results)
|
||||
}
|
||||
} else {
|
||||
completion([])
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let query = IssueQuery(owner: owner, repo: repo, number: number)
|
||||
apollo.fetch(query: query) { (result, error) in
|
||||
if let issue = result?.data?.repository?.issue {
|
||||
createViewModels(issue: issue, width: width) { results in
|
||||
completion(results)
|
||||
}
|
||||
} else {
|
||||
completion([])
|
||||
}
|
||||
} else {
|
||||
completion([])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,26 @@ func createViewModels(
|
||||
}
|
||||
}
|
||||
|
||||
func createViewModels(
|
||||
pullRequest: PullRequestQuery.Data.Repository.PullRequest,
|
||||
width: CGFloat,
|
||||
completion: @escaping ([IGListDiffable]) -> ()
|
||||
) {
|
||||
DispatchQueue.global().async {
|
||||
let result = createViewModels(
|
||||
number: pullRequest.number,
|
||||
title: pullRequest.title,
|
||||
labelableFields: pullRequest.fragments.labelableFields,
|
||||
commentFields: pullRequest.fragments.commentFields,
|
||||
reactionFields: pullRequest.fragments.reactionFields,
|
||||
width: width
|
||||
)
|
||||
DispatchQueue.main.async {
|
||||
completion(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func titleStringSizing(title: String, width: CGFloat) -> NSAttributedStringSizing {
|
||||
let attributedString = NSAttributedString(
|
||||
string: title,
|
||||
|
||||
@@ -15,6 +15,7 @@ final class IssuesViewController: UIViewController, IGListAdapterDataSource, Fee
|
||||
fileprivate let owner: String
|
||||
fileprivate let repo: String
|
||||
fileprivate let number: Int
|
||||
fileprivate let pullRequest: Bool
|
||||
fileprivate var issue: IssueQuery.Data.Repository.Issue?
|
||||
fileprivate var models = [IGListDiffable]()
|
||||
lazy fileprivate var feed: Feed = { Feed(viewController: self, delegate: self) }()
|
||||
@@ -23,12 +24,14 @@ final class IssuesViewController: UIViewController, IGListAdapterDataSource, Fee
|
||||
client: GithubClient,
|
||||
owner: String,
|
||||
repo: String,
|
||||
number: Int
|
||||
number: Int,
|
||||
pullRequest: Bool
|
||||
) {
|
||||
self.client = client
|
||||
self.owner = owner
|
||||
self.repo = repo
|
||||
self.number = number
|
||||
self.pullRequest = pullRequest
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
title = "\(owner)/\(repo)#\(number)"
|
||||
}
|
||||
@@ -70,7 +73,7 @@ final class IssuesViewController: UIViewController, IGListAdapterDataSource, Fee
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
number: number,
|
||||
pullRequest: false,
|
||||
pullRequest: pullRequest,
|
||||
width: view.bounds.width
|
||||
) { results in
|
||||
self.models = results
|
||||
|
||||
@@ -40,7 +40,8 @@ final class RepoNotificationsSectionController: IGListGenericSectionController<N
|
||||
client: client,
|
||||
owner: object.owner,
|
||||
repo: object.repo,
|
||||
number: object.number
|
||||
number: object.number,
|
||||
pullRequest: object.type == .pullRequest
|
||||
)
|
||||
viewController?.navigationController?.pushViewController(controller, animated: true)
|
||||
}
|
||||
|
||||
@@ -313,10 +313,10 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
292FCAC81EDFCC510026635E /* Comments */,
|
||||
2963A9381EE258C20066509C /* GithubClient+Issues.swift */,
|
||||
292FCAE61EDFCC510026635E /* IssueEvent.swift */,
|
||||
292FCAE81EDFCC510026635E /* IssueState.swift */,
|
||||
292FCAE91EDFCC510026635E /* IssuesViewController.swift */,
|
||||
2963A9381EE258C20066509C /* GithubClient+Issues.swift */,
|
||||
292FCAEA1EDFCC510026635E /* IssueViewModels.swift */,
|
||||
292FCAEC1EDFCC510026635E /* Labels */,
|
||||
292FCAF31EDFCC510026635E /* Title */,
|
||||
|
||||
Reference in New Issue
Block a user