File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed
Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -56,15 +56,24 @@ export const useGitHubData = (getOctokit: () => any) => {
5656 after : page > 1 ? ( cursorsRef . current ?. [ type ] ?. [ page - 1 ] ?? null ) : null ,
5757 } ) ;
5858
59- if ( ! cursorsRef . current [ type ] ) {
60- cursorsRef . current [ type ] = { } ;
61- }
62- cursorsRef . current [ type ] [ page ] = response . search . pageInfo . endCursor ;
59+ const items = response . search . edges . map ( ( edge : any ) => {
60+ const n = edge . node ;
61+ const base = {
62+ id : n . databaseId ,
63+ title : n . title ,
64+ html_url : n . url ,
65+ created_at : n . createdAt ,
66+ state : n . state ,
67+ repository_url : n . repository . url ,
68+ } ;
69+ return n . mergedAt ? { ...base , pull_request : { merged_at : n . mergedAt } } : base ;
70+ } ) ;
71+
72+ // cache cursor for pagination
73+ if ( ! cursorsRef . current [ type ] ) cursorsRef . current [ type ] = { } ;
74+ cursorsRef . current [ type ] [ page ] = response . search . pageInfo . endCursor ?? null ;
6375
64- return {
65- items : response . search . edges . map ( ( edge : any ) => edge . node ) ,
66- total : response . search . issueCount ,
67- } ;
76+ return { items, total : response . search . issueCount } ;
6877 } ;
6978
7079 const fetchData = useCallback (
You can’t perform that action at this time.
0 commit comments