diff --git a/ui/js/actions/search.js b/ui/js/actions/search.js index b56c752cc..6bdb10592 100644 --- a/ui/js/actions/search.js +++ b/ui/js/actions/search.js @@ -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, + }) } }