2017-04-24 16:17:36 +02:00
|
|
|
import { createSelector } from 'reselect'
|
|
|
|
|
|
|
|
export const _selectState = state => state.search || {}
|
|
|
|
|
|
|
|
export const selectSearchQuery = createSelector(
|
|
|
|
_selectState,
|
|
|
|
(state) => state.query
|
|
|
|
)
|
|
|
|
|
|
|
|
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,
|
|
|
|
(query, byQuery) => byQuery[query] || []
|
|
|
|
)
|
2017-04-30 05:19:59 +02:00
|
|
|
|
|
|
|
export const selectSearchActivated = createSelector(
|
|
|
|
_selectState,
|
|
|
|
(state) => !!state.activated
|
|
|
|
)
|