1- import React from 'react'
2- import 'whatwg-fetch'
1+ import React from 'react' ;
2+ import 'whatwg-fetch' ;
33
44import Header from './components/Timeline/Header' ;
55import AsyncContent from './ContentSearch' ;
66
7- import data from './data.json'
7+ import data from './data.json' ;
88// const rootUrl = `https://api.github.com`
99// const endpoint = `/users/fullstackreact/events`
1010
@@ -16,7 +16,7 @@ class SearchableContent extends React.Component {
1616 loading : false , // <~ set loading to false
1717 activities : [ ] ,
1818 searchFilter : ''
19- }
19+ } ;
2020 }
2121
2222 // Update the data when the component mounts
@@ -26,7 +26,7 @@ class SearchableContent extends React.Component {
2626
2727 componentWillReceiveProps ( nextProps ) {
2828 // Check to see if the requestRefresh prop has changed
29- if ( nextProps . requestRefresh !== this . props . requestRefresh ) {
29+ if ( nextProps . requestRefresh === true ) {
3030 this . setState ( { loading : true } , this . updateData ) ;
3131 }
3232 }
@@ -35,50 +35,53 @@ class SearchableContent extends React.Component {
3535 this . setState ( {
3636 searchFilter : val ,
3737 loading : true
38- } )
38+ } ) ;
3939 }
4040
4141 onComponentRefresh ( ) {
42- this . setState ( { loading : false } )
42+ this . setState ( { loading : false } ) ;
4343 }
4444
4545 // Call out to github and refresh directory
4646 updateData ( ) {
4747 const { activities, searchFilter} = this . state ;
4848
49- const filter = searchFilter !== '' &&
50- ( e => e . actor . login . match ( new RegExp ( searchFilter ) ) ) ;
49+ const filter =
50+ searchFilter !== '' &&
51+ ( e => e . actor . login . match ( new RegExp ( searchFilter ) ) ) ;
5152
52- const fetchDataOrCache = ( ) => Promise . resolve ( activities )
53+ const fetchDataOrCache = ( ) => Promise . resolve ( activities ) ;
5354
5455 // Use cached data if we have it
5556 return fetchDataOrCache ( )
5657 . then ( json => json || data )
57- . then ( json => filter ? json . filter ( filter ) : json )
58+ . then ( json => ( filter ? json . filter ( filter ) : json ) )
5859 . then ( json => {
5960 if ( activities . length === 0 ) {
60- this . setState ( { activities : json } )
61+ this . setState ( { activities : json } ) ;
6162 }
6263 return json ;
6364 } )
64- . then ( json => json . slice ( 0 , 4 ) )
65+ . then ( json => json . slice ( 0 , 4 ) ) ;
6566 }
6667
6768 render ( ) {
6869 const { loading} = this . state ;
69-
70+
7071 return (
7172 < div className = "notificationsFrame" >
7273 < Header
73- onSearch = { this . handleSearch . bind ( this ) }
74- title = "Github activity" />
75- < AsyncContent
74+ onSearch = { this . handleSearch . bind ( this ) }
75+ title = "Github activity"
76+ />
77+ < AsyncContent
7678 requestRefresh = { loading }
7779 onComponentRefresh = { this . onComponentRefresh . bind ( this ) }
78- fetchData = { this . updateData . bind ( this ) } />
80+ fetchData = { this . updateData . bind ( this ) }
81+ />
7982 </ div >
80- )
83+ ) ;
8184 }
8285}
8386
84- export default SearchableContent
87+ export default SearchableContent ;
0 commit comments