even smarter search
This commit is contained in:
parent
21818c57a8
commit
12f965f473
1 changed files with 20 additions and 2 deletions
|
@ -9,10 +9,18 @@ import {
|
||||||
import {
|
import {
|
||||||
doResolveUri,
|
doResolveUri,
|
||||||
} from 'actions/content'
|
} from 'actions/content'
|
||||||
|
import {
|
||||||
|
doNavigate,
|
||||||
|
} from 'actions/app'
|
||||||
|
import {
|
||||||
|
selectCurrentPage,
|
||||||
|
} from 'selectors/app'
|
||||||
|
|
||||||
export function doSearchContent(query) {
|
export function doSearchContent(query) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
const state = getState()
|
const state = getState()
|
||||||
|
const page = selectCurrentPage(state)
|
||||||
|
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
return dispatch({
|
return dispatch({
|
||||||
|
@ -25,6 +33,8 @@ export function doSearchContent(query) {
|
||||||
data: { query }
|
data: { query }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if(page != 'discover' && query != undefined) dispatch(doNavigate('discover'))
|
||||||
|
|
||||||
lighthouse.search(query).then(results => {
|
lighthouse.search(query).then(results => {
|
||||||
results.forEach(result => {
|
results.forEach(result => {
|
||||||
const uri = lbryuri.build({
|
const uri = lbryuri.build({
|
||||||
|
@ -47,8 +57,16 @@ export function doSearchContent(query) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doActivateSearch() {
|
export function doActivateSearch() {
|
||||||
return {
|
return function(dispatch, getState) {
|
||||||
type: types.ACTIVATE_SEARCH,
|
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…
Add table
Reference in a new issue