2017-04-24 16:17:36 +02:00
|
|
|
import { createSelector } from 'reselect'
|
2017-05-07 14:50:32 +02:00
|
|
|
import {
|
2017-05-11 02:59:47 +02:00
|
|
|
selectPageTitle,
|
|
|
|
selectCurrentPage,
|
|
|
|
selectCurrentUri
|
2017-05-07 14:50:32 +02:00
|
|
|
} from 'selectors/app'
|
2017-04-24 16:17:36 +02:00
|
|
|
|
|
|
|
export const _selectState = state => state.search || {}
|
|
|
|
|
2017-05-11 02:59:47 +02:00
|
|
|
export const selectSearchQuery = createSelector(
|
2017-05-12 01:28:43 +02:00
|
|
|
_selectState,
|
|
|
|
(state) => state.query
|
2017-05-11 02:59:47 +02:00
|
|
|
)
|
|
|
|
|
2017-04-24 16:17:36 +02:00
|
|
|
export const selectIsSearching = createSelector(
|
|
|
|
_selectState,
|
|
|
|
(state) => !!state.searching
|
|
|
|
)
|
|
|
|
|
|
|
|
export const selectSearchResults = createSelector(
|
|
|
|
_selectState,
|
|
|
|
(state) => state.results || {}
|
|
|
|
)
|
|
|
|
|
|
|
|
export const selectSearchResultsByQuery = createSelector(
|
|
|
|
selectSearchResults,
|
|
|
|
(results) => results.byQuery || {}
|
|
|
|
)
|
|
|
|
|
|
|
|
export const selectCurrentSearchResults = createSelector(
|
|
|
|
selectSearchQuery,
|
|
|
|
selectSearchResultsByQuery,
|
2017-05-11 02:59:47 +02:00
|
|
|
(query, byQuery) => byQuery[query]
|
2017-04-24 16:17:36 +02:00
|
|
|
)
|
2017-04-30 05:19:59 +02:00
|
|
|
|
2017-05-07 14:50:32 +02:00
|
|
|
|
2017-05-11 02:59:47 +02:00
|
|
|
export const selectWunderBarAddress = createSelector(
|
2017-05-12 01:28:43 +02:00
|
|
|
selectCurrentPage,
|
2017-05-11 02:59:47 +02:00
|
|
|
selectPageTitle,
|
2017-05-07 14:50:32 +02:00
|
|
|
selectSearchQuery,
|
2017-05-12 01:28:43 +02:00
|
|
|
(page, title, query) => page != "search" ? title : (query ? query : title)
|
2017-05-11 02:59:47 +02:00
|
|
|
)
|
2017-05-07 14:50:32 +02:00
|
|
|
|
2017-05-11 02:59:47 +02:00
|
|
|
export const selectWunderBarIcon = createSelector(
|
|
|
|
selectCurrentPage,
|
|
|
|
selectCurrentUri,
|
|
|
|
(page, uri) => {
|
|
|
|
switch (page) {
|
|
|
|
case 'search':
|
|
|
|
return 'icon-search'
|
|
|
|
case 'settings':
|
|
|
|
return 'icon-gear'
|
|
|
|
case 'help':
|
|
|
|
return 'icon-question'
|
|
|
|
case 'report':
|
|
|
|
return 'icon-file'
|
|
|
|
case 'downloaded':
|
|
|
|
return 'icon-folder'
|
|
|
|
case 'published':
|
|
|
|
return 'icon-folder'
|
|
|
|
case 'start':
|
|
|
|
return 'icon-file'
|
|
|
|
case 'rewards':
|
|
|
|
return 'icon-bank'
|
|
|
|
case 'wallet':
|
|
|
|
case 'send':
|
|
|
|
case 'receive':
|
|
|
|
return 'icon-bank'
|
|
|
|
case 'show':
|
|
|
|
return 'icon-file'
|
|
|
|
case 'publish':
|
|
|
|
return 'icon-upload'
|
|
|
|
case 'developer':
|
|
|
|
return 'icon-file'
|
|
|
|
case 'developer':
|
|
|
|
return 'icon-code'
|
|
|
|
case 'discover':
|
|
|
|
return 'icon-home'
|
|
|
|
}
|
2017-05-07 14:50:32 +02:00
|
|
|
}
|
2017-05-11 02:59:47 +02:00
|
|
|
)
|