even smarter search
This commit is contained in:
parent
e1d23667bc
commit
8c09469858
1 changed files with 20 additions and 2 deletions
|
@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue