@@ -99,29 +99,32 @@ const removeStarFromRepository = repositoryId => {
9999 } ) ;
100100} ;
101101
102- const resolveIssuesQuery = queryResult => state => {
103- const oldIssues = state . organization
104- ? state . organization . repository . issues . edges
105- : [ ] ;
106-
107- const {
108- edges : newIssues ,
109- } = queryResult . data . data . organization . repository . issues ;
102+ const resolveIssuesQuery = ( queryResult , cursor ) => state => {
103+ const { data, errors } = queryResult . data ;
104+
105+ if ( ! cursor ) {
106+ return {
107+ organization : data . organization ,
108+ errors,
109+ } ;
110+ }
110111
112+ const { edges : oldIssues } = state . organization . repository . issues ;
113+ const { edges : newIssues } = data . organization . repository . issues ;
111114 const updatedIssues = [ ...oldIssues , ...newIssues ] ;
112115
113116 return {
114117 organization : {
115- ...queryResult . data . data . organization ,
118+ ...data . organization ,
116119 repository : {
117- ...queryResult . data . data . organization . repository ,
120+ ...data . organization . repository ,
118121 issues : {
119- ...queryResult . data . data . organization . repository . issues ,
122+ ...data . organization . repository . issues ,
120123 edges : updatedIssues ,
121124 } ,
122125 } ,
123126 } ,
124- errors : queryResult . data . errors ,
127+ errors,
125128 } ;
126129} ;
127130
@@ -192,7 +195,7 @@ class App extends Component {
192195
193196 onFetchFromGitHub = ( path , cursor ) => {
194197 getIssuesOfRepository ( path , cursor ) . then ( queryResult =>
195- this . setState ( resolveIssuesQuery ( queryResult ) ) ,
198+ this . setState ( resolveIssuesQuery ( queryResult , cursor ) ) ,
196199 ) ;
197200 } ;
198201
0 commit comments