File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -16,28 +16,29 @@ const url = 'http://ajax.googleapis.com/ajax/services/feed/load' +
16
16
'?v=1.0&num=10&q=https://reactjsnews.com/feed.xml' ;
17
17
18
18
let items = [ ] ;
19
- let fetching = null ;
19
+ let lastFetchTask ;
20
20
let lastFetchTime = new Date ( 1970 , 0 , 1 ) ;
21
21
22
22
const news = {
23
23
type : new List ( NewsItemType ) ,
24
24
resolve ( ) {
25
- if ( fetching ) {
26
- return fetching ;
25
+ if ( lastFetchTask ) {
26
+ return lastFetchTask ;
27
27
}
28
28
29
29
if ( ( new Date ( ) - lastFetchTime ) > 1000 * 60 * 10 /* 10 mins */ ) {
30
30
lastFetchTime = new Date ( ) ;
31
- fetch ( url )
31
+ lastFetchTask = fetch ( url )
32
32
. then ( response => response . json ( ) )
33
33
. then ( data => {
34
34
if ( data . responseStatus === 200 ) {
35
35
items = data . responseData . feed . entries ;
36
- fetching = null ;
37
36
}
38
37
39
38
return items ;
40
39
} ) ;
40
+
41
+ return lastFetchTask ;
41
42
}
42
43
43
44
return items ;
You can’t perform that action at this time.
0 commit comments