@@ -37,22 +37,30 @@ export default class WebviewLoader implements vscode.Disposable {
3737
3838 if ( command === "fetchAnalyzedData" || command === "refresh" ) {
3939 try {
40- const baseBranchName = ( payload && JSON . parse ( payload ) ) ?? ( await fetchCurrentBranch ( ) ) ;
41- const storedAnalyzedData = context . workspaceState . get < ClusterNode [ ] > (
42- `${ ANALYZE_DATA_KEY } _${ baseBranchName } `
43- ) ;
44- analyzedData = storedAnalyzedData ;
45- if ( ! storedAnalyzedData ) {
46- console . log ( "No cache Data" ) ;
47- console . log ( "baseBranchName : " , baseBranchName ) ;
48- analyzedData = await fetchClusterNodes ( baseBranchName ) ;
49- context . workspaceState . update ( `${ ANALYZE_DATA_KEY } _${ baseBranchName } ` , analyzedData ) ;
50- } else console . log ( "Cache data exists" ) ;
51-
52- console . log ( "Current Stored data" ) ;
53- context . workspaceState . keys ( ) . forEach ( ( key ) => {
54- console . log ( key ) ;
55- } ) ;
40+ const requestPayload = payload ? JSON . parse ( payload ) : { } ;
41+ const { baseBranchName, perPage, lastCommitId } = requestPayload ;
42+ const currentBranch = baseBranchName ?? ( await fetchCurrentBranch ( ) ) ;
43+
44+ if ( perPage ) {
45+ console . log ( `Paging request: perPage=${ perPage } , lastCommitId=${ lastCommitId } ` ) ;
46+ analyzedData = await fetchClusterNodes ( currentBranch , perPage , lastCommitId ) ;
47+ } else {
48+ const cacheKey = `${ ANALYZE_DATA_KEY } _${ currentBranch } ` ;
49+ const storedAnalyzedData = context . workspaceState . get < ClusterNode [ ] > ( cacheKey ) ;
50+
51+ if ( storedAnalyzedData ) {
52+ console . log ( "Cache data exists" ) ;
53+ analyzedData = storedAnalyzedData ;
54+ } else {
55+ console . log ( "No cache Data" ) ;
56+ analyzedData = await fetchClusterNodes ( currentBranch ) ;
57+ context . workspaceState . update ( cacheKey , analyzedData ) ;
58+ }
59+ console . log ( "Current Stored data" ) ;
60+ context . workspaceState . keys ( ) . forEach ( ( key ) => {
61+ console . log ( key ) ;
62+ } ) ;
63+ }
5664
5765 const resMessage = {
5866 command,
@@ -158,7 +166,15 @@ export default class WebviewLoader implements vscode.Disposable {
158166
159167type GithruFetcher < D = unknown , P extends unknown [ ] = [ ] > = ( ...params : P ) => Promise < D > ;
160168type GithruFetcherMap = {
161- fetchClusterNodes : GithruFetcher < ClusterNode [ ] , [ string ] > ;
169+ fetchClusterNodes : GithruFetcher <
170+ {
171+ clusterNodes : ClusterNode [ ] ;
172+ isLastPage : boolean | undefined ;
173+ nextCommitId : string | null | undefined ;
174+ isPRSuccess : boolean ;
175+ } ,
176+ [ string ?, number ?, string ?]
177+ > ;
162178 fetchBranches : GithruFetcher < { branchList : string [ ] ; head : string | null } > ;
163179 fetchCurrentBranch : GithruFetcher < string > ;
164180 fetchGithubInfo : GithruFetcher < { owner : string ; repo : string } > ;
0 commit comments