File tree Expand file tree Collapse file tree 1 file changed +54
-6
lines changed Expand file tree Collapse file tree 1 file changed +54
-6
lines changed Original file line number Diff line number Diff line change 11import React from 'react' ;
2- import { Query } from 'react-apollo' ;
2+ import { Query , ApolloConsumer } from 'react-apollo' ;
33import { withState } from 'recompose' ;
44
55import { GET_ISSUES_OF_REPOSITORY } from './queries' ;
@@ -52,18 +52,39 @@ const updateQuery = (previousResult, { fetchMoreResult }) => {
5252 } ;
5353} ;
5454
55+ const prefetchIssues = (
56+ client ,
57+ repositoryOwner ,
58+ repositoryName ,
59+ issueState ,
60+ ) => {
61+ const nextIssueState = TRANSITION_STATE [ issueState ] ;
62+
63+ if ( isShow ( nextIssueState ) ) {
64+ client . query ( {
65+ query : GET_ISSUES_OF_REPOSITORY ,
66+ variables : {
67+ repositoryOwner,
68+ repositoryName,
69+ issueState : nextIssueState ,
70+ } ,
71+ } ) ;
72+ }
73+ } ;
74+
5575const Issues = ( {
5676 repositoryOwner,
5777 repositoryName,
5878 issueState,
5979 onChangeIssueState,
6080} ) => (
6181 < div className = "Issues" >
62- < ButtonUnobtrusive
63- onClick = { ( ) => onChangeIssueState ( TRANSITION_STATE [ issueState ] ) }
64- >
65- { TRANSITION_LABELS [ issueState ] }
66- </ ButtonUnobtrusive >
82+ < IssueFilter
83+ repositoryOwner = { repositoryOwner }
84+ repositoryName = { repositoryName }
85+ issueState = { issueState }
86+ onChangeIssueState = { onChangeIssueState }
87+ />
6788
6889 { isShow ( issueState ) && (
6990 < Query
@@ -114,6 +135,33 @@ const Issues = ({
114135 </ div >
115136) ;
116137
138+ const IssueFilter = ( {
139+ repositoryOwner,
140+ repositoryName,
141+ issueState,
142+ onChangeIssueState,
143+ } ) => (
144+ < ApolloConsumer >
145+ { client => (
146+ < ButtonUnobtrusive
147+ onClick = { ( ) =>
148+ onChangeIssueState ( TRANSITION_STATE [ issueState ] )
149+ }
150+ onMouseOver = { ( ) =>
151+ prefetchIssues (
152+ client ,
153+ repositoryOwner ,
154+ repositoryName ,
155+ issueState ,
156+ )
157+ }
158+ >
159+ { TRANSITION_LABELS [ issueState ] }
160+ </ ButtonUnobtrusive >
161+ ) }
162+ </ ApolloConsumer >
163+ ) ;
164+
117165const IssueList = ( {
118166 issues,
119167 loading,
You can’t perform that action at this time.
0 commit comments