@@ -11,7 +11,8 @@ import {
11
11
import { ConnectedCodeView } from 'components/code-view' ;
12
12
import {
13
13
updateFileUrl ,
14
- toggleCodeView
14
+ toggleCodeView ,
15
+ setLastUpdate ,
15
16
} from 'reducers/ui-filters'
16
17
import { resultsFromLocationSelector } from 'selectors/results' ;
17
18
import 'whatwg-fetch' ;
@@ -26,7 +27,16 @@ export class SearchForm extends React.Component {
26
27
this . handleSearchCaseSensitiveToggle = this . handleSearchCaseSensitiveToggle . bind ( this )
27
28
this . handleLocationChange = this . handleLocationChange . bind ( this )
28
29
this . getSearchParamsFromProps = this . getSearchParamsFromProps . bind ( this ) ;
29
- this . debounceUpdateSearch = _ . debounce ( this . updateSearch , 200 )
30
+ this . debounceUpdateSearch = _ . debounce ( this . updateSearch , 200 ) ;
31
+ }
32
+
33
+ componentDidMount ( ) {
34
+ fetch ( '/api/lastupdate' )
35
+ . then ( ( response ) => {
36
+ return response . json ( )
37
+ } ) . then ( ( response ) => {
38
+ this . props . setLastUpdate ( moment ( response ) )
39
+ } )
30
40
}
31
41
32
42
getSearchParamsFromProps ( ) {
@@ -94,7 +104,7 @@ export class SearchForm extends React.Component {
94
104
}
95
105
96
106
render ( ) {
97
- var { searchString, searchStringRegEx, searchStringCaseSensitive, location, results, full, className} = this . props ;
107
+ var { searchString, searchStringRegEx, searchStringCaseSensitive, location, results, full, className, lastUpdate } = this . props ;
98
108
var hashes = results . map ( ( result ) => result . hash ) ;
99
109
return (
100
110
< div className = { "SearchForm " + className } >
@@ -127,12 +137,12 @@ export class SearchForm extends React.Component {
127
137
( searchString === '' && location === '' ) ?
128
138
< span > Type in the searchbox to get started! </ span > :
129
139
< span >
130
- { results . length } { searchString === '' ? 'files found' : ' results found for string' } < code > { searchString === '' ? '' : `'${ searchString } '` } </ code > at < code > { location === '' ? 'any path' : `'${ location } '` } </ code >
140
+ Search results for string < code > { searchString === '' ? '' : `'${ searchString } '` } </ code > at < code > { location === '' ? 'any path' : `'${ location } '` } </ code >
131
141
</ span >
132
142
}
133
143
</ div >
134
144
< div className = "Results" ref = { ( ref ) => this . resultView = this . resultView || ref } >
135
- < ConnectedInfiniteScroll loadMore = { ( ) => this . loadMore ( hashes ) } hasMore = { true } >
145
+ < ConnectedInfiniteScroll loadMore = { ( ) => this . loadMore ( hashes ) } hasMore = { searchString || location } >
136
146
{
137
147
results . map ( ( result , i ) => {
138
148
var { file, lno, above_lines, the_line, below_lines} = result ;
@@ -152,6 +162,14 @@ export class SearchForm extends React.Component {
152
162
</ ConnectedInfiniteScroll >
153
163
</ div >
154
164
</ div >
165
+ < div className = "Footer" >
166
+ < div className = "left" >
167
+ { lastUpdate ? `Last update: ${ lastUpdate . fromNow ( ) } ` : null }
168
+ </ div >
169
+ < div className = "right" >
170
+ Made with < a href = "https://github.com/codegrep/codegrep" className = "ion-ios-heart pulse" > </ a > by Swit and Gott
171
+ </ div >
172
+ </ div >
155
173
</ div >
156
174
)
157
175
}
@@ -165,12 +183,14 @@ export const ConnectedSearchForm = connect(
165
183
location : state . search . form . location ,
166
184
results : state . search . results ,
167
185
full : state . uiFilters . views . full ,
186
+ lastUpdate : state . uiFilters . lastUpdate ,
168
187
} ) ,
169
188
{
170
189
updateSearchString,
171
190
updateSearchStringRegEx,
172
191
updateSearchStringCaseSensitive,
173
192
updateLocation,
174
193
updateResults,
194
+ setLastUpdate,
175
195
}
176
196
) ( SearchForm ) ;
0 commit comments