fix search not happening after changing search options
This commit is contained in:
parent
4e0e1e2f2b
commit
16e45c452f
2 changed files with 11 additions and 2 deletions
|
@ -2,7 +2,12 @@ import { connect } from 'react-redux';
|
|||
import { doToast, SETTINGS } from 'lbry-redux';
|
||||
import { withRouter } from 'react-router';
|
||||
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 { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import analytics from 'analytics';
|
||||
|
@ -23,6 +28,7 @@ const select = (state, props) => {
|
|||
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_MATURE)(state),
|
||||
uris: uris,
|
||||
isAuthenticated: selectUserVerifiedEmail(state),
|
||||
searchOptions: selectSearchOptions(state),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ type AdditionalOptions = {
|
|||
|
||||
type Props = {
|
||||
search: (string, AdditionalOptions) => void,
|
||||
searchOptions: {},
|
||||
isSearching: boolean,
|
||||
location: UrlLocation,
|
||||
uris: Array<string>,
|
||||
|
@ -38,6 +39,7 @@ export default function SearchPage(props: Props) {
|
|||
isSearching,
|
||||
showNsfw,
|
||||
isAuthenticated,
|
||||
searchOptions,
|
||||
} = props;
|
||||
const { push } = useHistory();
|
||||
const urlParams = new URLSearchParams(location.search);
|
||||
|
@ -81,12 +83,13 @@ export default function SearchPage(props: Props) {
|
|||
}
|
||||
|
||||
const stringifiedOptions = JSON.stringify(additionalOptions);
|
||||
const stringifiedSearchOptions = JSON.stringify(searchOptions);
|
||||
useEffect(() => {
|
||||
if (urlQuery) {
|
||||
const jsonOptions = JSON.parse(stringifiedOptions);
|
||||
search(urlQuery, jsonOptions);
|
||||
}
|
||||
}, [search, urlQuery, stringifiedOptions]);
|
||||
}, [search, urlQuery, stringifiedOptions, stringifiedSearchOptions]);
|
||||
|
||||
return (
|
||||
<Page>
|
||||
|
|
Loading…
Reference in a new issue