fix search not happening after changing search options

This commit is contained in:
Sean Yesmunt 2020-12-03 16:31:38 -05:00
parent 4e0e1e2f2b
commit 16e45c452f
2 changed files with 11 additions and 2 deletions

View file

@ -2,7 +2,12 @@ import { connect } from 'react-redux';
import { doToast, SETTINGS } from 'lbry-redux'; import { doToast, SETTINGS } from 'lbry-redux';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import { doSearch } from 'redux/actions/search'; import { doSearch } from 'redux/actions/search';
import { selectIsSearching, makeSelectSearchUris, makeSelectQueryWithOptions } from 'redux/selectors/search'; import {
selectIsSearching,
makeSelectSearchUris,
makeSelectQueryWithOptions,
selectSearchOptions,
} from 'redux/selectors/search';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import { selectUserVerifiedEmail } from 'redux/selectors/user'; import { selectUserVerifiedEmail } from 'redux/selectors/user';
import analytics from 'analytics'; import analytics from 'analytics';
@ -23,6 +28,7 @@ const select = (state, props) => {
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state), showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state),
uris: uris, uris: uris,
isAuthenticated: selectUserVerifiedEmail(state), isAuthenticated: selectUserVerifiedEmail(state),
searchOptions: selectSearchOptions(state),
}; };
}; };

View file

@ -19,6 +19,7 @@ type AdditionalOptions = {
type Props = { type Props = {
search: (string, AdditionalOptions) => void, search: (string, AdditionalOptions) => void,
searchOptions: {},
isSearching: boolean, isSearching: boolean,
location: UrlLocation, location: UrlLocation,
uris: Array<string>, uris: Array<string>,
@ -38,6 +39,7 @@ export default function SearchPage(props: Props) {
isSearching, isSearching,
showNsfw, showNsfw,
isAuthenticated, isAuthenticated,
searchOptions,
} = props; } = props;
const { push } = useHistory(); const { push } = useHistory();
const urlParams = new URLSearchParams(location.search); const urlParams = new URLSearchParams(location.search);
@ -81,12 +83,13 @@ export default function SearchPage(props: Props) {
} }
const stringifiedOptions = JSON.stringify(additionalOptions); const stringifiedOptions = JSON.stringify(additionalOptions);
const stringifiedSearchOptions = JSON.stringify(searchOptions);
useEffect(() => { useEffect(() => {
if (urlQuery) { if (urlQuery) {
const jsonOptions = JSON.parse(stringifiedOptions); const jsonOptions = JSON.parse(stringifiedOptions);
search(urlQuery, jsonOptions); search(urlQuery, jsonOptions);
} }
}, [search, urlQuery, stringifiedOptions]); }, [search, urlQuery, stringifiedOptions, stringifiedSearchOptions]);
return ( return (
<Page> <Page>