even smarter search

This commit is contained in:
6ea86b96 2017-04-30 10:31:20 +07:00 committed by Jeremy Kauffman
parent e1d23667bc
commit 8c09469858

View file

@ -9,10 +9,18 @@ import {
import {
doResolveUri,
} from 'actions/content'
import {
doNavigate,
} from 'actions/app'
import {
selectCurrentPage,
} from 'selectors/app'
export function doSearchContent(query) {
return function(dispatch, getState) {
const state = getState()
const page = selectCurrentPage(state)
if (!query) {
return dispatch({
@ -25,6 +33,8 @@ export function doSearchContent(query) {
data: { query }
})
if(page != 'discover' && query != undefined) dispatch(doNavigate('discover'))
lighthouse.search(query).then(results => {
results.forEach(result => {
const uri = lbryuri.build({
@ -47,8 +57,16 @@ export function doSearchContent(query) {
}
export function doActivateSearch() {
return {
type: types.ACTIVATE_SEARCH,
return function(dispatch, getState) {
const state = getState()
const page = selectCurrentPage(state)
const query = selectSearchQuery(state)
if(page != 'discover' && query != undefined) dispatch(doNavigate('discover'))
dispatch({
type: types.ACTIVATE_SEARCH,
})
}
}