@@ -17,36 +17,6 @@ protocol RepositoryQuery {
1717 func nextPageToken( from data: GraphQLSelectionSet ) -> String ?
1818}
1919
20- extension RepoIssuePagesQuery : RepositoryQuery {
21-
22- func summaryTypes( from data: GraphQLSelectionSet ) -> [ RepositoryIssueSummaryType ] {
23- guard let issues = data as? Data else { return [ ] }
24- return issues. repository? . issues. nodes? . compactMap { $0 } ?? [ ]
25- }
26-
27- func nextPageToken( from data: GraphQLSelectionSet ) -> String ? {
28- guard let issues = data as? Data else { return nil }
29- guard let pageInfo = issues. repository? . issues. pageInfo, pageInfo. hasNextPage else { return nil }
30- return pageInfo. endCursor
31- }
32-
33- }
34-
35- extension RepoPullRequestPagesQuery : RepositoryQuery {
36-
37- func summaryTypes( from data: GraphQLSelectionSet ) -> [ RepositoryIssueSummaryType ] {
38- guard let prs = data as? RepoPullRequestPagesQuery . Data else { return [ ] }
39- return prs. repository? . pullRequests. nodes? . compactMap { $0 } ?? [ ]
40- }
41-
42- func nextPageToken( from data: GraphQLSelectionSet ) -> String ? {
43- guard let prs = data as? RepoPullRequestPagesQuery . Data else { return nil }
44- guard let pageInfo = prs. repository? . pullRequests. pageInfo, pageInfo. hasNextPage else { return nil }
45- return pageInfo. endCursor
46- }
47-
48- }
49-
5020extension RepoSearchPagesQuery : RepositoryQuery {
5121
5222 func summaryTypes( from data: GraphQLSelectionSet ) -> [ RepositoryIssueSummaryType ] {
@@ -69,12 +39,34 @@ func createSummaryModel(
6939 ) -> RepositoryIssueSummaryModel ? {
7040 guard let date = node. repoEventFields. createdAt. githubDate else { return nil }
7141
72- let title = StyledTextBuilder ( styledText: StyledText (
42+ let builder = StyledTextBuilder ( styledText: StyledText (
7343 text: node. title,
74- style: Styles . Text. body. with ( foreground: Styles . Colors. Gray. dark. color)
75- ) ) . build ( )
44+ // style: Styles.Text.body.with(foreground: Styles.Colors.Gray.medium.color)
45+ style: Styles . Text. body
46+ ) )
47+ if let ciStatus = node. ciStatus {
48+ let iconName : String
49+ let color : UIColor
50+ switch ciStatus {
51+ case . pending:
52+ iconName = " primitive-dot "
53+ color = Styles . Colors. Yellow. medium. color
54+ case . failure:
55+ iconName = " x-small "
56+ color = Styles . Colors. Red. medium. color
57+ case . success:
58+ iconName = " check-small "
59+ color = Styles . Colors. Green. medium. color
60+ }
61+ if let icon = UIImage ( named: iconName) ? . withRenderingMode ( . alwaysTemplate) {
62+ builder. save ( )
63+ . add ( text: " \u{00A0} " )
64+ . add ( image: icon, attributes: [ . foregroundColor: color] )
65+ . restore ( )
66+ }
67+ }
7668 let string = StyledTextRenderer (
77- string: title ,
69+ string: builder . build ( ) ,
7870 contentSizeCategory: contentSizeCategory,
7971 inset: RepositorySummaryCell . titleInset
8072 ) . warm ( width: containerWidth)
@@ -87,7 +79,8 @@ func createSummaryModel(
8779 author: node. repoEventFields. author? . login ?? Constants . Strings. unknown,
8880 status: node. status,
8981 pullRequest: node. pullRequest,
90- labels: node. labelableFields. issueLabelModels
82+ labels: node. labelableFields. issueLabelModels,
83+ ciStatus: node. ciStatus
9184 )
9285}
9386
@@ -98,11 +91,13 @@ func createSummaryModel(
9891 containerWidth: CGFloat
9992 ) -> ( models: [ RepositoryIssueSummaryModel ] , nextPage: String ? ) {
10093 let nextPage = query. nextPageToken ( from: data)
101- let models : [ RepositoryIssueSummaryModel ] = query. summaryTypes ( from: data) . compactMap { ( node: RepositoryIssueSummaryType ) in
102- return createSummaryModel ( node, contentSizeCategory: contentSizeCategory, containerWidth: containerWidth)
103- } . sorted ( by: {
104- $0. created > $1. created
105- } )
94+ let models = query. summaryTypes ( from: data) . compactMap { node in
95+ return createSummaryModel (
96+ node,
97+ contentSizeCategory: contentSizeCategory,
98+ containerWidth: containerWidth
99+ )
100+ } . sorted { $0. created > $1. created }
106101 return ( models, nextPage)
107102}
108103
@@ -155,30 +150,6 @@ final class RepositoryClient {
155150 } )
156151 }
157152
158- func loadIssues(
159- nextPage: String ? = nil ,
160- containerWidth: CGFloat ,
161- completion: @escaping ( Result < RepositoryPayload > ) -> Void
162- ) {
163- loadPage (
164- query: RepoIssuePagesQuery ( owner: owner, name: name, after: nextPage, page_size: 30 ) ,
165- containerWidth: containerWidth,
166- completion: completion
167- )
168- }
169-
170- func loadPullRequests(
171- nextPage: String ? = nil ,
172- containerWidth: CGFloat ,
173- completion: @escaping ( Result < RepositoryPayload > ) -> Void
174- ) {
175- loadPage (
176- query: RepoPullRequestPagesQuery ( owner: owner, name: name, after: nextPage, page_size: 30 ) ,
177- containerWidth: containerWidth,
178- completion: completion
179- )
180- }
181-
182153 func searchIssues(
183154 query: String ,
184155 nextPage: String ? = nil ,
0 commit comments