Modifying Dashboard search clear button to clear all search params.

This commit is contained in:
Roland 2024-05-25 10:48:08 -06:00
parent bd8411bcd7
commit dd13534a39
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
7 changed files with 43 additions and 11 deletions

View file

@ -38,7 +38,7 @@ const SUGGESTED_APPS = [
export const useSearch = (defaultLimit = 48, totalPages = 0, emptySearch = false, model) => {
const navigate = useNavigate();
const {dateRange, setDateRange, months, setDates} = useSearchDate();
const {dateRange, setDateRange, months, setDates, isEmpty: datesIsEmpty} = useSearchDate();
const {searchParams, updateQuery, getLocationStr} = React.useContext(QueryContext);
// `searchStr` means actually fetch the files/zims.
const searchStr = searchParams.get('q');
@ -50,6 +50,9 @@ export const useSearch = (defaultLimit = 48, totalPages = 0, emptySearch = false
// archive/video/ebook/etc.
const model_ = searchParams.get('model') || model;
const anySearch = (!datesIsEmpty) || searchStr || (activeTags && activeTags.length > 0) || filter || model;
const isEmpty = !anySearch;
const setSearchStr = (value) => {
const searchQuery = {q: value, o: 0};
if (filter) {
@ -90,6 +93,7 @@ export const useSearch = (defaultLimit = 48, totalPages = 0, emptySearch = false
clearSearch,
setTags,
months, dateRange, setDateRange, setDates,
anySearch, isEmpty,
}
}