@@ -47,7 +47,7 @@ function buildUrl({base, q: {type, filterUser, author, repo}, sort, order, per_p
47
47
return query ;
48
48
}
49
49
50
- function contributorCount ( { access_token, contributor, repoPath, type} ) {
50
+ function contributorCount ( { access_token, contributor, repoPath, old = { } , type} ) {
51
51
let searchURL = buildUrl ( {
52
52
access_token,
53
53
base : "https://api.github.com/search/issues" ,
@@ -82,15 +82,9 @@ function contributorCount({access_token, contributor, repoPath, type}) {
82
82
obj [ `first${ type [ 0 ] . toUpperCase ( ) + type . slice ( 1 ) } Number` ] = json . items [ 0 ] . number ;
83
83
}
84
84
85
- if ( obj . prs ) {
86
- setStorageProperty ( contributor , repoPath , "lastUpdate" , obj . lastUpdate ) ;
87
- setStorageProperty ( contributor , repoPath , "prs" , obj . prs ) ;
88
- setStorageProperty ( contributor , repoPath , "firstPrNumber" , obj . firstPrNumber ) ;
89
- } else if ( obj . issues ) {
90
- setStorageProperty ( contributor , repoPath , "lastUpdate" , obj . lastUpdate ) ;
91
- setStorageProperty ( contributor , repoPath , "issues" , obj . issues ) ;
92
- setStorageProperty ( contributor , repoPath , "firstIssueNumber" , obj . firstIssueNumber ) ;
93
- }
85
+ obj = Object . assign ( old , obj ) ;
86
+
87
+ setStorage ( contributor , repoPath , obj ) ;
94
88
95
89
return obj ;
96
90
} ) ;
@@ -182,8 +176,8 @@ function update({ contributor, repoPath, currentNum }) {
182
176
getSyncStorage ( { "access_token" : null } )
183
177
. then ( ( res ) => {
184
178
Promise . all ( [
185
- contributorCount ( { access_token : res . access_token , type : "pr" , contributor, repoPath} ) ,
186
- contributorCount ( { access_token : res . access_token , type : "issue" , contributor, repoPath} )
179
+ contributorCount ( { old : storageRes , access_token : res . access_token , type : "pr" , contributor, repoPath} ) ,
180
+ contributorCount ( { old : storageRes , access_token : res . access_token , type : "issue" , contributor, repoPath} )
187
181
] )
188
182
. then ( ( [ prInfo , issueInfo ] ) => {
189
183
let repoInfo = Object . assign ( prInfo , issueInfo ) ;
0 commit comments