@@ -12,28 +12,51 @@ const repoData = R.map(
1212 R . pick ( [ 'id' , 'name' , 'description' , 'language' , 'owner' , 'stargazers_count' ] )
1313)
1414
15- export function watshData ( ) {
16- debug ( 'watshData' )
15+ // const RLog = x => debug('R log: ', x)
16+
17+ const reposIsEmpty = R . compose ( R . isEmpty , R . prop ( 'reposData' ) )
18+ const inputValueIsNotEmpty = R . compose ( R . not , R . isEmpty , R . prop ( 'inputValue' ) )
19+ const isNotSearching = R . compose ( R . not , R . prop ( 'searching' ) )
20+
21+ export const repoNotFound = R . allPass ( [
22+ reposIsEmpty ,
23+ inputValueIsNotEmpty ,
24+ isNotSearching ,
25+ ] )
26+
27+ /*
28+ export function repoNotFound() {
29+ return (
30+ R.isEmpty(store.reposData) &&
31+ !store.searching &&
32+ !R.isEmpty(store.inputValue)
33+ )
1734}
35+ */
1836
19- export function search ( val ) {
37+ export function search ( e ) {
2038 // console.log('search: ', val)
21- Pigeon . search ( val )
39+ const value = e . target . value
40+ store . markState ( 'inputValue' , value )
41+ store . markState ( 'searching' , true )
42+ Pigeon . search ( value )
2243}
2344
2445export function init ( selectedStore ) {
25- debug ( 'store' , store )
2646 store = selectedStore
47+ debug ( 'store' , store )
2748 Pigeon = new SearchService ( )
2849
2950 Pigeon . get ( ) . subscribe ( res => {
3051 debug ( 'Pigeon get: ' , res )
3152 // debug('washed: ', repoData(res.items))
53+ store . markState ( 'searching' , false )
3254 store . replaceRepos ( repoData ( res . items ) )
3355 } )
3456
3557 Pigeon . emptyInput ( ) . subscribe ( ( ) => {
3658 debug ( 'Pigeon get emptyInput!' )
59+ store . markState ( 'searching' , false )
3760 store . clearRepos ( )
3861 } )
3962}
0 commit comments