TagSpaces is an offline, open source, document manager with tagging support
Make saved search queries editable (#2248)
Stanimirc863cb42bcf5
diff --git a/src/renderer/components/EditSearchQuery.tsx b/src/renderer/components/EditSearchQuery.tsxnew file mode 100644index 000000000..4e744be9e--- /dev/null+++ b/src/renderer/components/EditSearchQuery.tsx@@ -0,0 +1,600 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2017-present TagSpaces GmbH+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import React from 'react';+import AppConfig from '-/AppConfig';+import {+ ArchiveIcon,+ AudioIcon,+ BookIcon,+ BookmarkIcon,+ DocumentIcon,+ EmailIcon,+ FileIcon,+ FolderIcon,+ InfoTooltipIcon,+ NoteIcon,+ PictureIcon,+ UntaggedIcon,+ VideoIcon,+} from '-/components/CommonIcons';+import { classes } from '-/components/SidePanels.css';+import TooltipTS from '-/components/Tooltip';+import TsIconButton from '-/components/TsIconButton';+import TsTextField from '-/components/TsTextField';+import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';+import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';+import { isDesktopMode } from '-/reducers/settings';+import Box from '@mui/material/Box';+import FormControl from '@mui/material/FormControl';+import FormHelperText from '@mui/material/FormHelperText';+import InputAdornment from '@mui/material/InputAdornment';+import MenuItem from '@mui/material/MenuItem';+import OutlinedInput from '@mui/material/OutlinedInput';+import Select from '@mui/material/Select';+import ToggleButton from '@mui/material/ToggleButton';+import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';+import Typography from '@mui/material/Typography';+import { DatePicker, LocalizationProvider } from '@mui/x-date-pickers';+import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';+import { useTranslation } from 'react-i18next';+import { useSelector } from 'react-redux';+import TagsSelect from './TagsSelect';+import { useSearchQueryContext } from '-/hooks/useSearchQueryContext';+import { Stack } from '@mui/material';++interface Props {+ executeSearchOnEnter?: boolean;+}++function EditSearchQuery(props: Props) {+ const { t } = useTranslation();+ const { executeSearchOnEnter } = props;+ const desktopMode = useSelector(isDesktopMode);+ const { tempSearchQuery, setTempSearchQuery, clearSearch, executeSearch } =+ useSearchQueryContext();+ const { isIndexing } = useLocationIndexContext();++ const handleFileSizeChange = (event: React.ChangeEvent<HTMLInputElement>) => {+ const { target } = event;+ const { value, name } = target;+ if (name === 'fileSize') {+ setTempSearchQuery({ fileSize: value });+ }+ };++ const handleLastModifiedChange = (+ event: React.ChangeEvent<HTMLInputElement>,+ ) => {+ const { target } = event;+ const { value, name } = target;++ if (name === 'lastModified') {+ setTempSearchQuery({ lastModified: value });+ }+ };++ function removeTags(tagsArray, removeTagsArray) {+ // eslint-disable-next-line react/no-access-state-in-setstate+ return tagsArray.filter((tag) =>+ removeTagsArray.some((valueTag) => valueTag.title !== tag.title),+ );+ }++ const handleTagFieldChange = (name, value, reason) => {+ let sq;+ if (reason === 'remove-value') {+ if (name === 'tagsAND') {+ const tags = removeTags(tempSearchQuery.tagsAND, value);+ sq = tags ? { tagsAND: tags } : undefined;+ } else if (name === 'tagsNOT') {+ const tags = removeTags(tempSearchQuery.tagsNOT, value);+ sq = tags ? { tagsNOT: tags } : undefined;+ } else if (name === 'tagsOR') {+ const tags = removeTags(tempSearchQuery.tagsOR, value);+ sq = tags ? { tagsOR: tags } : undefined;+ }+ } else {+ // eslint-disable-next-line no-lonely-if+ if (name === 'tagsAND') {+ sq = { tagsAND: value };+ } else if (name === 'tagsNOT') {+ sq = { tagsNOT: value };+ } else if (name === 'tagsOR') {+ sq = { tagsOR: value };+ }+ }+ if (sq) {+ setTempSearchQuery(sq);+ } else {+ clearSearch();+ }+ };++ const handleSearchTermChange = (event) => {+ const { target } = event;+ const { value } = target;+ setTempSearchQuery({ textQuery: value });+ };++ const switchSearchBoxing = (+ event: React.MouseEvent<HTMLElement>,+ boxing: 'location' | 'folder' | 'global',+ ) => {+ if (boxing !== null) {+ setTempSearchQuery({ searchBoxing: boxing });+ }+ };++ const switchSearchType = (+ event: React.MouseEvent<HTMLElement>,+ type: 'fuzzy' | 'semistrict' | 'strict',+ ) => {+ if (type !== null) {+ setTempSearchQuery({ searchType: type });+ }+ };++ const handleFileTypeChange = (event: React.ChangeEvent<HTMLInputElement>) => {+ const { target } = event;+ const { value, name } = target;++ if (name === 'fileTypes') {+ const types = JSON.parse(value);+ setTempSearchQuery({ fileTypes: types });+ }+ };++ return (+ <Stack component="form" spacing={2} noValidate autoComplete="off">+ <TsTextField+ id="searchTerm"+ label={t('core:searchQueryInfo')}+ value={tempSearchQuery.textQuery}+ onChange={handleSearchTermChange}+ size={desktopMode ? 'small' : 'medium'}+ onKeyDown={() => {+ if (executeSearchOnEnter) {+ executeSearch();+ }+ }}+ slotProps={{+ input: {+ endAdornment: (+ <InputAdornment position="end">+ <TooltipTS+ title={+ <>+ <Typography variant="subtitle1" color="inherit">+ Tips for the extended search+ </Typography>+ <Typography variant="subtitle2" color="inherit">+ π‘ <b>{'sun'}</b> - will match entries having the word+ sun but also san or sum in the name+ <br />+ π‘ <b>{'=sun'}</b> - will match entries having exactly+ the word sun in the name+ <br />+ π‘ <b>{'"sun and beach"'}</b> - will match entries+ having `sun and beachΒ΄ in the name+ <br />+ π‘ <b>{"'sun 'beach"}</b> - will match entries having+ sun or beach in the name+ <br />+ π‘ <b>{'!sun'}</b> - will match entries which do not+ contain sun+ <br />+ π‘ <b>{'^sun'}</b> - will match entries beginning with+ sun+ <br />+ π‘ <b>{'!^sun'}</b> - will match entries witch do not+ begin with sun+ <br />+ π‘ <b>{'.pdf$'}</b> - will match entries ending with+ <br />+ π‘ <b>{'!.pdf$'}</b> - will match entries not ending+ with .pdf+ <br />+ </Typography>+ </>+ }+ >+ <InfoTooltipIcon />+ </TooltipTS>+ </InputAdornment>+ ),+ },+ }}+ />+ <FormControl+ className={classes.formControl}+ disabled={isIndexing !== undefined}+ >+ <ToggleButtonGroup+ onChange={switchSearchBoxing}+ size="small"+ exclusive+ style={{ marginBottom: 10, alignSelf: 'center' }}+ value={tempSearchQuery.searchBoxing}+ >+ <ToggleButton value="location">+ <TooltipTS title={t('searchPlaceholder')}>+ <div>{t('location')}</div>+ </TooltipTS>+ </ToggleButton>+ <ToggleButton value="folder">+ <TooltipTS title={t('searchCurrentFolderWithSubFolders')}>+ <div>{t('folder')}</div>+ </TooltipTS>+ </ToggleButton>+ <ToggleButton value="global">+ <TooltipTS title={t('searchInAllLocationTooltip')}>+ <div>{t('globalSearch')}</div>+ </TooltipTS>+ </ToggleButton>+ </ToggleButtonGroup>+ </FormControl>+ <FormControl+ className={classes.formControl}+ disabled={isIndexing !== undefined}+ >+ <ToggleButtonGroup+ onChange={switchSearchType}+ size="small"+ exclusive+ style={{ marginBottom: 10, alignSelf: 'center' }}+ value={tempSearchQuery.searchType}+ >+ <ToggleButton value="fuzzy" data-tid="fuzzySearchTID">+ <TooltipTS title={t('searchTypeFuzzyTooltip')}>+ <div>{t('searchTypeFuzzy')}</div>+ </TooltipTS>+ </ToggleButton>+ <ToggleButton value="semistrict" data-tid="semiStrictSearchTID">+ <TooltipTS title={t('searchTypeSemiStrictTooltip')}>+ <div>{t('searchTypeSemiStrict')}</div>+ </TooltipTS>+ </ToggleButton>+ <ToggleButton value="strict" data-tid="strictSearchTID">+ <TooltipTS title={t('searchTypeStrictTooltip')}>+ <div>{t('searchTypeStrict')}</div>+ </TooltipTS>+ </ToggleButton>+ </ToggleButtonGroup>+ </FormControl>+ <FormControl+ className={classes.formControl}+ disabled={isIndexing !== undefined}+ >+ <ToggleButtonGroup+ onChange={() => {+ setTempSearchQuery({+ forceIndexing: !tempSearchQuery.forceIndexing,+ });+ }}+ size="small"+ exclusive+ style={{ marginBottom: 10, alignSelf: 'center' }}+ value={tempSearchQuery.forceIndexing}+ >+ <ToggleButton value={false}>+ <TooltipTS title={t('useCurrentIndexTooltip')}>+ <div>{t('useCurrentIndex')}</div>+ </TooltipTS>+ </ToggleButton>+ <ToggleButton value={true} data-tid="forceIndexingTID">+ <TooltipTS title={t('forceReindexTooltip')}>+ <div>{t('forceReindex')}</div>+ </TooltipTS>+ </ToggleButton>+ </ToggleButtonGroup>+ </FormControl>+ <FormControl+ className={classes.formControl}+ disabled={isIndexing !== undefined}+ >+ <TagsSelect+ dataTid="searchTagsAndTID"+ placeholderText={t('core:selectTags')}+ label={t('core:mustContainTheseTags')}+ tags={tempSearchQuery.tagsAND}+ handleChange={handleTagFieldChange}+ tagSearchType="tagsAND"+ tagMode="remove"+ />+ </FormControl>+ <FormControl+ className={classes.formControl}+ disabled={isIndexing !== undefined}+ >+ <TagsSelect+ dataTid="searchTagsOrTID"+ placeholderText={t('core:selectTags')}+ tags={tempSearchQuery.tagsOR}+ label={t('core:atLeastOneOfTheseTags')}+ handleChange={handleTagFieldChange}+ tagSearchType="tagsOR"+ tagMode="remove"+ />+ </FormControl>+ <FormControl+ className={classes.formControl}+ disabled={isIndexing !== undefined}+ >+ <TagsSelect+ dataTid="searchTagsNotTID"+ placeholderText={t('core:selectTags')}+ tags={tempSearchQuery.tagsNOT}+ label={t('core:noneOfTheseTags')}+ handleChange={handleTagFieldChange}+ tagSearchType="tagsNOT"+ tagMode="remove"+ />+ </FormControl>+ <FormControl+ className={classes.formControl}+ disabled={isIndexing !== undefined}+ >+ <TooltipTS title={t('filterByTypTooltip')}>+ <FormHelperText style={{ marginLeft: 0 }}>+ {t('core:fileType')}+ </FormHelperText>+ <Select+ fullWidth+ value={JSON.stringify(tempSearchQuery.fileTypes)}+ onChange={handleFileTypeChange}+ size={desktopMode ? 'small' : 'medium'}+ input={<OutlinedInput name="fileTypes" id="file-type" />}+ >+ <MenuItem value={JSON.stringify(AppConfig.SearchTypeGroups.any)}>+ {t('core:anyType')}+ </MenuItem>+ <MenuItem+ value={JSON.stringify(AppConfig.SearchTypeGroups.folders)}+ >+ <TsIconButton size="small">+ <FolderIcon />+ </TsIconButton>+ {t('core:searchFolders')}+ </MenuItem>+ <MenuItem value={JSON.stringify(AppConfig.SearchTypeGroups.files)}>+ <TsIconButton size="small">+ <FileIcon />+ </TsIconButton>+ {t('core:searchFiles')}+ </MenuItem>+ <MenuItem+ value={JSON.stringify(AppConfig.SearchTypeGroups.untagged)}+ >+ <TsIconButton size="small">+ <UntaggedIcon />+ </TsIconButton>+ {t('core:searchUntaggedEntries')}+ </MenuItem>+ <MenuItem+ value={JSON.stringify(AppConfig.SearchTypeGroups.images)}+ title={AppConfig.SearchTypeGroups.images.toString()}+ >+ <TsIconButton size="small">+ <PictureIcon />+ </TsIconButton>+ {t('core:searchPictures')}+ </MenuItem>+ <MenuItem+ value={JSON.stringify(AppConfig.SearchTypeGroups.documents)}+ title={AppConfig.SearchTypeGroups.documents.toString()}+ >+ <TsIconButton size="small">+ <DocumentIcon />+ </TsIconButton>+ {t('core:searchDocuments')}+ </MenuItem>+ <MenuItem+ value={JSON.stringify(AppConfig.SearchTypeGroups.notes)}+ title={AppConfig.SearchTypeGroups.notes.toString()}+ >+ <TsIconButton size="small">+ <NoteIcon />+ </TsIconButton>+ {t('core:searchNotes')}+ </MenuItem>+ <MenuItem+ value={JSON.stringify(AppConfig.SearchTypeGroups.audio)}+ title={AppConfig.SearchTypeGroups.audio.toString()}+ >+ <TsIconButton size="small">+ <AudioIcon />+ </TsIconButton>+ {t('core:searchAudio')}+ </MenuItem>+ <MenuItem+ value={JSON.stringify(AppConfig.SearchTypeGroups.video)}+ title={AppConfig.SearchTypeGroups.video.toString()}+ >+ <TsIconButton size="small">+ <VideoIcon />+ </TsIconButton>+ {t('core:searchVideoFiles')}+ </MenuItem>+ <MenuItem+ value={JSON.stringify(AppConfig.SearchTypeGroups.archives)}+ title={AppConfig.SearchTypeGroups.archives.toString()}+ >+ <TsIconButton size="small">+ <ArchiveIcon />+ </TsIconButton>+ {t('core:searchArchives')}+ </MenuItem>+ <MenuItem+ value={JSON.stringify(AppConfig.SearchTypeGroups.bookmarks)}+ title={AppConfig.SearchTypeGroups.bookmarks.toString()}+ >+ <TsIconButton size="small">+ <BookmarkIcon />+ </TsIconButton>+ {t('core:searchBookmarks')}+ </MenuItem>+ <MenuItem+ value={JSON.stringify(AppConfig.SearchTypeGroups.ebooks)}+ title={AppConfig.SearchTypeGroups.ebooks.toString()}+ >+ <TsIconButton size="small">+ <BookIcon />+ </TsIconButton>+ {t('core:searchEbooks')}+ </MenuItem>+ <MenuItem+ value={JSON.stringify(AppConfig.SearchTypeGroups.emails)}+ title={AppConfig.SearchTypeGroups.emails.toString()}+ >+ <TsIconButton size="small">+ <EmailIcon />+ </TsIconButton>+ {t('core:searchEmails')}+ </MenuItem>+ </Select>+ </TooltipTS>+ </FormControl>+ <FormControl+ className={classes.formControl}+ disabled={isIndexing !== undefined}+ >+ <TooltipTS title={t('filterBySizeTooltip')}>+ <FormHelperText style={{ marginLeft: 0 }}>+ {t('core:sizeSearchTitle')}+ </FormHelperText>+ <Select+ fullWidth+ value={tempSearchQuery.fileSize}+ onChange={handleFileSizeChange}+ size={desktopMode ? 'small' : 'medium'}+ input={<OutlinedInput name="fileSize" id="file-size" />}+ displayEmpty+ >+ <MenuItem value="">{t('core:sizeAny')}</MenuItem>+ <MenuItem value="sizeEmpty">{t('core:sizeEmpty')}</MenuItem>+ <MenuItem value="sizeTiny">+ {t('core:sizeTiny')}+ (< 10KB)+ </MenuItem>+ <MenuItem value="sizeVerySmall">+ {t('core:sizeVerySmall')}+ (< 100KB)+ </MenuItem>+ <MenuItem value="sizeSmall">+ {t('core:sizeSmall')}+ (< 1MB)+ </MenuItem>+ <MenuItem value="sizeMedium">+ {t('core:sizeMedium')}+ (< 50MB)+ </MenuItem>+ <MenuItem value="sizeLarge">+ {t('core:sizeLarge')}+ (< 1GB)+ </MenuItem>+ <MenuItem value="sizeHuge">+ {t('core:sizeHuge')}+ (> 1GB)+ </MenuItem>+ </Select>+ </TooltipTS>+ </FormControl>+ <FormControl+ className={classes.formControl}+ disabled={isIndexing !== undefined}+ >+ <TooltipTS title={t('filterByLastModifiedDateTooltip')}>+ <FormHelperText style={{ marginLeft: 0 }}>+ {t('core:lastModifiedSearchTitle')}+ </FormHelperText>+ <Select+ fullWidth+ value={tempSearchQuery.lastModified}+ onChange={handleLastModifiedChange}+ size={desktopMode ? 'small' : 'medium'}+ input={<OutlinedInput name="lastModified" id="modification-date" />}+ displayEmpty+ >+ <MenuItem value="">{t('core:anyTime')}</MenuItem>+ <MenuItem value="today">{t('core:today')}</MenuItem>+ <MenuItem value="yesterday">{t('core:yesterday')}</MenuItem>+ <MenuItem value="past7Days">{t('core:past7Days')}</MenuItem>+ <MenuItem value="past30Days">{t('core:past30Days')}</MenuItem>+ <MenuItem value="past6Months">{t('core:past6Months')}</MenuItem>+ <MenuItem value="pastYear">{t('core:pastYear')}</MenuItem>+ <MenuItem value="moreThanYear">{t('core:moreThanYear')}</MenuItem>+ </Select>+ </TooltipTS>+ </FormControl>+ <FormControl className={classes.formControl}>+ <TooltipTS title={t('enterTimePeriodTooltip')}>+ <LocalizationProvider dateAdapter={AdapterDateFns}>+ <Box position="relative" display="inline-flex">+ <div>+ <FormHelperText style={{ marginLeft: 0, marginTop: 0 }}>+ {t('core:enterTagTimePeriodFrom')}+ </FormHelperText>+ <DatePicker+ disabled={isIndexing !== undefined}+ format="yyyy-MM-dd"+ value={+ tempSearchQuery.tagTimePeriodFrom+ ? new Date(tempSearchQuery.tagTimePeriodFrom)+ : undefined+ }+ onChange={(fromDataTime: Date) => {+ if (fromDataTime) {+ setTempSearchQuery({+ tagTimePeriodFrom: fromDataTime.getTime(),+ });+ }+ }}+ />+ </div>+ <div style={{ marginLeft: 5 }}>+ <FormHelperText style={{ marginLeft: 0, marginTop: 0 }}>+ {t('core:enterTagTimePeriodTo')}+ </FormHelperText>+ <DatePicker+ disabled={isIndexing !== undefined}+ format="yyyy-MM-dd"+ value={+ tempSearchQuery.tagTimePeriodTo+ ? new Date(tempSearchQuery.tagTimePeriodTo)+ : undefined+ }+ onChange={(toDataTime: Date) => {+ if (toDataTime) {+ setTempSearchQuery({+ tagTimePeriodTo: toDataTime.getTime(),+ });+ }+ }}+ />+ </div>+ </Box>+ </LocalizationProvider>+ </TooltipTS>+ </FormControl>+ </Stack>+ );+}++export default EditSearchQuery;diff --git a/src/renderer/components/SearchAutocomplete.tsx b/src/renderer/components/SearchAutocomplete.tsxindex fb9dce460..266d9a9e2 100644--- a/src/renderer/components/SearchAutocomplete.tsx+++ b/src/renderer/components/SearchAutocomplete.tsx@@ -72,12 +72,11 @@ import { isDesktopMode } from '-/reducers/settings';import { useSavedSearchesContext } from '-/hooks/useSavedSearchesContext';import { useBrowserHistoryContext } from '-/hooks/useBrowserHistoryContext';import useFirstRender from '-/utils/useFirstRender';+import { useSearchQueryContext } from '-/hooks/useSearchQueryContext';interface Props {style?: any;open: boolean;- textQuery: string;- setTextQuery: (value: string) => void;setAnchorSearch: (el: HTMLButtonElement) => void;}@@ -104,6 +103,7 @@ function SearchAutocomplete(props: Props) {searchQuery,setSearchQuery,} = useDirectoryContentContext();+ const { tempSearchQuery, setTempSearchQuery } = useSearchQueryContext();const { openHistoryItem } = useBrowserHistoryContext();const { isIndexing, searchAllLocations, searchLocationIndex } =useLocationIndexContext();@@ -120,7 +120,7 @@ function SearchAutocomplete(props: Props) {const openLinkDispatch = (link, options) => openLink(link, options);- const { setTextQuery, textQuery, open, setAnchorSearch } = props;+ const { open, setAnchorSearch } = props;const [openSavedSearches, setOpenSavedSearches] =useState<null | HTMLElement>(null);const searchOptions = useRef<Array<SearchOptionType>>(getSearchOptions());@@ -215,11 +215,10 @@ function SearchAutocomplete(props: Props) {let txtQuery = '';if (searchQuery.textQuery) {- setTextQuery(searchQuery.textQuery);txtQuery = searchQuery.textQuery;emptySearch = false;- } else if (textQuery) {- txtQuery = textQuery;+ } else if (tempSearchQuery && tempSearchQuery.textQuery) {+ txtQuery = tempSearchQuery.textQuery;emptySearch = false;}@@ -344,7 +343,10 @@ function SearchAutocomplete(props: Props) {forceUpdate();}} else if (event.key === 'Backspace' || event.keyCode === 8) {- if (textQuery.length === 0 && actionValues.current.length > 0) {+ if (+ tempSearchQuery.textQuery.length === 0 &&+ actionValues.current.length > 0+ ) {actionValues.current = actionValues.current.slice(0, -1);resetActions(actionValues.current);isOpen.current = true;@@ -356,7 +358,7 @@ function SearchAutocomplete(props: Props) {};function resetValues(exceptions: Array<SearchOptionType>) {- setTextQuery('');+ setTempSearchQuery({ textQuery: '' }, true);if (!exceptions.some((action) =>isAction(action.action, SearchQueryComposition.SCOPE),@@ -499,10 +501,10 @@ function SearchAutocomplete(props: Props) {return;}if (- textQuery.startsWith('ts:?ts') ||- textQuery.startsWith(AppConfig.tsProtocol + '?ts')+ tempSearchQuery.textQuery.startsWith('ts:?ts') ||+ tempSearchQuery.textQuery.startsWith(AppConfig.tsProtocol + '?ts')) {- openLinkDispatch(textQuery, { fullWidth: false });+ openLinkDispatch(tempSearchQuery.textQuery, { fullWidth: false });clearSearch();return;}@@ -516,7 +518,7 @@ function SearchAutocomplete(props: Props) {SearchQueryComposition.TAG_NOT,);const sQuery: TS.SearchQuery = {- textQuery: textQuery,+ textQuery: tempSearchQuery.textQuery,tagsAND,tagsOR,tagsNOT,@@ -983,7 +985,7 @@ function SearchAutocomplete(props: Props) {tagsNOT,executeSearch: false,});- setTextQuery('');+ setTempSearchQuery({ textQuery: '' });if (hasOptionsChanged) {changeOptions(option.action);}@@ -1088,7 +1090,7 @@ function SearchAutocomplete(props: Props) {// executeSearch();} else if (option.action === undefined) {// text query- setTextQuery(option.label);+ setTempSearchQuery({ textQuery: option.label }, true);const pAction = actions[actions.length - 1];if (pAction && isAction(pAction.action, SearchActions.FILTER)) {@@ -1121,7 +1123,7 @@ function SearchAutocomplete(props: Props) {const inputArr = valueArr.filter((action) => !actionValues.current.some((v) => v.label === action),);- setTextQuery(inputArr.join(' '));+ setTempSearchQuery({ textQuery: inputArr.join(' ') }, true);forceUpdate();} else if (reason === 'clear') {clearSearch();@@ -1182,7 +1184,6 @@ function SearchAutocomplete(props: Props) {if (actions.length === 0) {searchOptions.current = getSearchOptions();currentOptions.current = undefined;- // textQuery.current = ''; todo remove tagsAnd from search query} else {actionValues.current = execActions(actions, [], false);searchOptions.current = getSearchOptions().filter(@@ -1272,7 +1273,9 @@ function SearchAutocomplete(props: Props) {v.fullName ? v.fullName : v.label,)}onChange={handleChange}- inputValue={textQuery}+ inputValue={+ tempSearchQuery.textQuery ? tempSearchQuery.textQuery : ''+ }onInputChange={handleInputChange}open={isOpen.current}filterOptions={(options: Array<SearchOptionType>, state: any) => {diff --git a/src/renderer/components/SearchBox.tsx b/src/renderer/components/SearchBox.tsxindex d7621e13f..be37e2e1f 100644--- a/src/renderer/components/SearchBox.tsx+++ b/src/renderer/components/SearchBox.tsx@@ -17,35 +17,22 @@*/import React, { useState } from 'react';-import { alpha, useTheme } from '@mui/material/styles';import Popover from '@mui/material/Popover';import SearchPopover from '-/components/SearchPopover';import SearchAutocomplete from '-/components/SearchAutocomplete';-import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';interface Props {open: boolean;}function SearchBox(props: Props) {- const theme = useTheme();- const { searchQuery } = useDirectoryContentContext();const [anchorSearch, setAnchorSearch] = useState<HTMLButtonElement | null>(null,);- const [textQuery, setTextQuery] = useState<string>(- searchQuery.textQuery || '',- );-return (<>- <SearchAutocomplete- open={props.open}- textQuery={textQuery}- setTextQuery={setTextQuery}- setAnchorSearch={setAnchorSearch}- />+ <SearchAutocomplete open={props.open} setAnchorSearch={setAnchorSearch} />{props.open && (<Popoveropen={Boolean(anchorSearch)}@@ -74,11 +61,7 @@ function SearchBox(props: Props) {WebkitAppRegion: 'no-drag',}}>- <SearchPopover- onClose={() => setAnchorSearch(null)}- textQuery={textQuery}- setTextQuery={setTextQuery}- />+ <SearchPopover onClose={() => setAnchorSearch(null)} /></Popover>)}</>diff --git a/src/renderer/components/SearchPopover.tsx b/src/renderer/components/SearchPopover.tsxindex a3dec630b..74db393b4 100644--- a/src/renderer/components/SearchPopover.tsx+++ b/src/renderer/components/SearchPopover.tsx@@ -16,410 +16,75 @@**/+import React from 'react';import AppConfig from '-/AppConfig';-import {- ArchiveIcon,- AudioIcon,- BookIcon,- BookmarkIcon,- CloseIcon,- CreateFileIcon,- DocumentIcon,- EditIcon,- EmailIcon,- FileIcon,- FolderIcon,- InfoTooltipIcon,- NoteIcon,- PictureIcon,- UntaggedIcon,- VideoIcon,-} from '-/components/CommonIcons';+import { CloseIcon, CreateFileIcon, EditIcon } from '-/components/CommonIcons';import { SidePanel, classes } from '-/components/SidePanels.css';import TooltipTS from '-/components/Tooltip';import TsButton from '-/components/TsButton';import TsIconButton from '-/components/TsIconButton';-import TsTextField from '-/components/TsTextField';-import SaveSearchDialog from '-/components/dialogs/SaveSearchDialog';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';import { useSavedSearchesContext } from '-/hooks/useSavedSearchesContext';-import {- getMaxSearchResults,- getShowUnixHiddenEntries,- isDesktopMode,-} from '-/reducers/settings';-import { haveSearchFilters } from '-/services/search';+import { isDesktopMode } from '-/reducers/settings';import { openURLExternally } from '-/services/utils-io';import { TS } from '-/tagspaces.namespace';-import { parseGeoLocation, parseLatLon } from '-/utils/geo';-import Box from '@mui/material/Box';import ButtonGroup from '@mui/material/ButtonGroup';import FormControl from '@mui/material/FormControl';import FormHelperText from '@mui/material/FormHelperText';import Grid from '@mui/material/Grid';-import InputAdornment from '@mui/material/InputAdornment';import MenuItem from '@mui/material/MenuItem';-import OutlinedInput from '@mui/material/OutlinedInput';import Select from '@mui/material/Select';-import ToggleButton from '@mui/material/ToggleButton';-import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';import Typography from '@mui/material/Typography';-import { useTheme } from '@mui/material/styles';-import { DatePicker, LocalizationProvider } from '@mui/x-date-pickers';-import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';-import { mergeWithExtractedTags } from '@tagspaces/tagspaces-common/misc';import Links from 'assets/links';-import React, { useReducer, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import { useSelector } from 'react-redux';-import TagsSelect from './TagsSelect';+import EditSearchQuery from '-/components/EditSearchQuery';+import { useSearchQueryContext } from '-/hooks/useSearchQueryContext';interface Props {style?: any;- hideDrawer?: () => void;+ //hideDrawer?: () => void;onClose: () => void;- textQuery: string;- setTextQuery: (value: string) => void;}function SearchPopover(props: Props) {const { t } = useTranslation();+ const { onClose } = props;const desktopMode = useSelector(isDesktopMode);- const theme = useTheme();- const {- openCurrentDirectory,- currentDirectoryPath,- searchQuery,- setSearchQuery,- exitSearchMode,- } = useDirectoryContentContext();+ const { openCurrentDirectory, setSearchQuery, exitSearchMode } =+ useDirectoryContentContext();const { searches } = useSavedSearchesContext();+ const {+ tempSearchQuery,+ setTempSearchQuery,+ openSaveSearchDialog,+ executeSearch,+ } = useSearchQueryContext();const { getIndex, isIndexing } = useLocationIndexContext();- const [, forceUpdate] = useReducer((x) => x + 1, 0, undefined);- const maxSearchResults = useSelector(getMaxSearchResults);- const showUnixHiddenEntries = useSelector(getShowUnixHiddenEntries);- const fileTypes = useRef<Array<string>>(- searchQuery.fileTypes- ? searchQuery.fileTypes- : AppConfig.SearchTypeGroups.any,- );-- const searchBoxing = searchQuery.searchBoxing- ? searchQuery.searchBoxing- : 'location';- const searchType = searchQuery.searchType ? searchQuery.searchType : 'fuzzy';- const lastModified = useRef<string>(- searchQuery.lastModified ? searchQuery.lastModified : '',- );- const [saveSearchDialogOpened, setSaveSearchDialogOpened] =- useState<TS.SearchQuery>(undefined);- const [tagPlace, setTagPlace] = useState<string>(' ');- const [tagPlaceHelper, setTagPlaceHelper] = useState<string>(' ');- const tagTimePeriodFrom = searchQuery.tagTimePeriodFrom // useRef<number | null>(- ? searchQuery.tagTimePeriodFrom- : undefined;- const tagTimePeriodTo = searchQuery.tagTimePeriodTo //useRef<number | null>(- ? searchQuery.tagTimePeriodTo- : undefined;- const [tagPlaceLat, setTagPlaceLat] = useState<number | null>(null);- const [tagPlaceLong, setTagPlaceLong] = useState<number | null>(null);- // const [tagPlaceRadius, setTagPlaceRadius] = useState<number>(0);- const forceIndexing = useRef<boolean>(- searchQuery.forceIndexing ? searchQuery.forceIndexing : false,- );- const fileSize = useRef<string>(- searchQuery.fileSize ? searchQuery.fileSize : '',- );-- const handleFileTypeChange = (event: React.ChangeEvent<HTMLInputElement>) => {- const { target } = event;- const { value, name } = target;-- if (name === 'fileTypes') {- const types = JSON.parse(value);- fileTypes.current = types;- setSearchQuery({- ...searchQuery,- searchBoxing: searchBoxing,- fileTypes: types,- showUnixHiddenEntries,- executeSearch: false,- });- }- };-- const handleFileSizeChange = (event: React.ChangeEvent<HTMLInputElement>) => {- const { target } = event;- const { value, name } = target;- if (name === 'fileSize') {- fileSize.current = value;- setSearchQuery({- ...searchQuery,- searchBoxing: searchBoxing,- fileSize: value,- showUnixHiddenEntries,- executeSearch: false,- });- }- };-- const handleLastModifiedChange = (- event: React.ChangeEvent<HTMLInputElement>,- ) => {- const { target } = event;- const { value, name } = target;-- if (name === 'lastModified') {- lastModified.current = value;- setSearchQuery({- ...searchQuery,- searchBoxing: searchBoxing,- lastModified: value,- showUnixHiddenEntries,- executeSearch: false,- });- }- };const handleSavedSearchChange = (event: React.ChangeEvent<HTMLInputElement>,) => {const { target } = event;const { value } = target;- const savedSearch = searches.find((search) => search.uuid === value);+ const savedSearch: TS.SearchQuery = searches.find(+ (search) => search.uuid === value,+ );if (!savedSearch) {return true;}- props.setTextQuery(savedSearch.textQuery ? savedSearch.textQuery : '');- fileTypes.current = savedSearch.fileTypes;- lastModified.current = savedSearch.lastModified;- fileSize.current = savedSearch.fileSize;- forceIndexing.current = savedSearch.forceIndexing;- setSearchQuery({- ...savedSearch,- tagTimePeriodFrom: savedSearch.tagTimePeriodFrom,- tagTimePeriodTo: savedSearch.tagTimePeriodTo,- showUnixHiddenEntries,- });- };-- function removeTags(tagsArray, removeTagsArray) {- // eslint-disable-next-line react/no-access-state-in-setstate- return tagsArray.filter((tag) =>- removeTagsArray.some((valueTag) => valueTag.title !== tag.title),- );- }-- const handleTagFieldChange = (name, value, reason) => {- let sq;- if (reason === 'remove-value') {- if (name === 'tagsAND') {- sq = {- ...searchQuery,- tagsAND: removeTags(searchQuery.tagsAND, value),- };- } else if (name === 'tagsNOT') {- sq = {- ...searchQuery,- tagsNOT: removeTags(searchQuery.tagsNOT, value),- };- } else if (name === 'tagsOR') {- sq = {- ...searchQuery,- tagsOR: removeTags(searchQuery.tagsOR, value),- };- }- } else {- // eslint-disable-next-line no-lonely-if- if (name === 'tagsAND') {- sq = { ...searchQuery, tagsAND: value };- } else if (name === 'tagsNOT') {- sq = { ...searchQuery, tagsNOT: value };- } else if (name === 'tagsOR') {- sq = { ...searchQuery, tagsOR: value };- }- }- if (!haveSearchFilters(sq)) {- clearSearch();- } else {- setSearchQuery({- ...sq,- searchBoxing: searchBoxing,- showUnixHiddenEntries,- executeSearch: false,- });- }- };-- const handleSearchTermChange = (event) => {- const { target } = event;- const { value } = target;- props.setTextQuery(value);- };-- const handlePlaceChange = (event) => {- const { target } = event;- const { value } = target;- let lat = null;- let lng = null;- let tagPHelper;-- const location = parseGeoLocation(value);- if (location !== undefined) {- ({ lat, lng } = location);- } else {- const latLon = parseLatLon(value);- if (latLon) {- ({ lat } = latLon);- lng = latLon.lon;- }- }-- if (lat && lng) {- tagPHelper = 'Place at lat: ' + lat + ' long: ' + lng;- } else {- tagPHelper = '';- }- setTagPlace(value);- setTagPlaceLat(lat);- setTagPlaceLong(lng);- setTagPlaceHelper(tagPHelper);- };-- const startSearch = (event) => {- if (event.key === 'Enter' || event.keyCode === 13) {- if (props.hideDrawer) {- props.hideDrawer();- }- executeSearch();- }+ setTempSearchQuery({ ...savedSearch }, true);};const clearSearch = () => {- props.setTextQuery('');- fileTypes.current = AppConfig.SearchTypeGroups.any;- lastModified.current = '';- setTagPlace(' ');- setTagPlaceHelper(' ');- setTagPlaceLat(null);- setTagPlaceLong(null);- forceIndexing.current = false;- fileSize.current = '';- props.onClose();+ onClose();openCurrentDirectory().then(() => {setSearchQuery({});exitSearchMode();});};- const saveSearch = (isNew = true) => {- const tagsAND = mergeWithExtractedTags(- props.textQuery,- searchQuery.tagsAND,- '+',- );- const tagsOR = mergeWithExtractedTags(- props.textQuery,- searchQuery.tagsOR,- '|',- );- const tagsNOT = mergeWithExtractedTags(- props.textQuery,- searchQuery.tagsNOT,- '-',- );- setSaveSearchDialogOpened({- uuid: isNew ? undefined : searchQuery.uuid,- title: searchQuery.title,- textQuery: props.textQuery,- tagsAND,- tagsOR,- tagsNOT,- searchBoxing: searchBoxing,- searchType: searchType,- fileTypes: fileTypes.current,- lastModified: lastModified.current,- fileSize: fileSize.current,- tagTimePeriodFrom: tagTimePeriodFrom,- tagTimePeriodTo: tagTimePeriodTo,- tagPlaceLat,- tagPlaceLong,- // tagPlaceRadius,- maxSearchResults: maxSearchResults,- currentDirectory: currentDirectoryPath,- forceIndexing: forceIndexing.current,- });- };-- const switchSearchBoxing = (- event: React.MouseEvent<HTMLElement>,- boxing: 'location' | 'folder' | 'global',- ) => {- if (boxing !== null) {- setSearchQuery({- ...searchQuery,- searchBoxing: boxing,- executeSearch: false,- });- }- };-- const switchSearchType = (- event: React.MouseEvent<HTMLElement>,- type: 'fuzzy' | 'semistrict' | 'strict',- ) => {- if (type !== null) {- setSearchQuery({- ...searchQuery,- searchType: type,- executeSearch: false,- });- }- };-- const executeSearch = () => {- const tagsAND = mergeWithExtractedTags(- props.textQuery,- searchQuery.tagsAND,- '+',- );- const tagsOR = mergeWithExtractedTags(- props.textQuery,- searchQuery.tagsOR,- '|',- );- const tagsNOT = mergeWithExtractedTags(- props.textQuery,- searchQuery.tagsNOT,- '-',- );- const query: TS.SearchQuery = {- textQuery: props.textQuery,- tagsAND,- tagsOR,- tagsNOT,- searchBoxing: searchBoxing,- searchType: searchType,- fileTypes: fileTypes.current,- lastModified: lastModified.current,- fileSize: fileSize.current,- tagTimePeriodFrom: tagTimePeriodFrom,- tagTimePeriodTo: tagTimePeriodTo,- tagPlaceLat,- tagPlaceLong,- // tagPlaceRadius,- maxSearchResults: maxSearchResults,- currentDirectory: currentDirectoryPath,- forceIndexing: forceIndexing.current,- showUnixHiddenEntries,- executeSearch: true,- };- console.log('Search object: ' + JSON.stringify(searchQuery));- setSearchQuery(query);- props.onClose();- };-const indexStatus = getIndex()? '(' + getIndex().length + ' indexed entries)': t('core:indexEmpty');@@ -446,7 +111,7 @@ function SearchPopover(props: Props) {<TsIconButtonstyle={{ marginLeft: 'auto', height: 40 }}data-tid="closeSearchTID"- onClick={props.onClose}+ onClick={onClose}><CloseIcon /></TsIconButton>@@ -491,7 +156,7 @@ function SearchPopover(props: Props) {displayEmptyfullWidthvariant="outlined"- value={searchQuery.uuid ? searchQuery.uuid : -1}+ value={tempSearchQuery.uuid ? tempSearchQuery.uuid : -1}><MenuItem value={-1} style={{ display: 'none' }} />{searches.length < 1 && (@@ -517,11 +182,11 @@ function SearchPopover(props: Props) {width: '100%',}}>- {searchQuery.uuid && (+ {tempSearchQuery.uuid && (<TsIconButtontooltip={t('editSavedSearchTitle')}data-tid="editSearchBtnTID"- onClick={() => saveSearch(false)}+ onClick={() => openSaveSearchDialog(tempSearchQuery.uuid)}><EditIcon /></TsIconButton>@@ -529,463 +194,16 @@ function SearchPopover(props: Props) {<TsIconButtontooltip={t('createNewSavedSearchTitle')}data-tid="addSearchBtnTID"- onClick={() => saveSearch()}+ onClick={() => openSaveSearchDialog()}><CreateFileIcon /></TsIconButton></ButtonGroup></Grid><Grid item xs={12}>- <TsTextField- id="searchTerm"- label={t('core:searchQueryInfo')}- value={props.textQuery}- onChange={handleSearchTermChange}- size={desktopMode ? 'small' : 'medium'}- onKeyDown={startSearch}- slotProps={{- input: {- endAdornment: (- <InputAdornment position="end">- <TooltipTS- title={- <>- <Typography variant="subtitle1" color="inherit">- Tips for the extended search- </Typography>- <Typography variant="subtitle2" color="inherit">- π‘ <b>{'sun'}</b> - will match entries having the- word sun but also san or sum in the name- <br />- π‘ <b>{'=sun'}</b> - will match entries having- exactly the word sun in the name- <br />- π‘ <b>{'"sun and beach"'}</b> - will match entries- having `sun and beachΒ΄ in the name- <br />- π‘ <b>{"'sun 'beach"}</b> - will match entries- having sun or beach in the name- <br />- π‘ <b>{'!sun'}</b> - will match entries which do- not contain sun- <br />- π‘ <b>{'^sun'}</b> - will match entries beginning- with sun- <br />- π‘ <b>{'!^sun'}</b> - will match entries witch do- not begin with sun- <br />- π‘ <b>{'.pdf$'}</b> - will match entries ending- with .pdf- <br />- π‘ <b>{'!.pdf$'}</b> - will match entries not- ending with .pdf- <br />- </Typography>- </>- }- >- <InfoTooltipIcon />- </TooltipTS>- </InputAdornment>- ),- },- }}- />+ <EditSearchQuery /></Grid></Grid>- <FormControl- className={classes.formControl}- disabled={isIndexing !== undefined}- >- <ToggleButtonGroup- onChange={switchSearchBoxing}- size="small"- exclusive- style={{ marginBottom: 10, alignSelf: 'center' }}- value={searchBoxing}- >- <ToggleButton value="location">- <TooltipTS title={t('searchPlaceholder')}>- <div>{t('location')}</div>- </TooltipTS>- </ToggleButton>- <ToggleButton value="folder">- <TooltipTS title={t('searchCurrentFolderWithSubFolders')}>- <div>{t('folder')}</div>- </TooltipTS>- </ToggleButton>- <ToggleButton value="global">- <TooltipTS title={t('searchInAllLocationTooltip')}>- <div>{t('globalSearch')}</div>- </TooltipTS>- </ToggleButton>- </ToggleButtonGroup>- </FormControl>- <FormControl- className={classes.formControl}- disabled={isIndexing !== undefined}- >- <ToggleButtonGroup- onChange={switchSearchType}- size="small"- exclusive- style={{ marginBottom: 10, alignSelf: 'center' }}- value={searchType}- >- <ToggleButton value="fuzzy" data-tid="fuzzySearchTID">- <TooltipTS title={t('searchTypeFuzzyTooltip')}>- <div>{t('searchTypeFuzzy')}</div>- </TooltipTS>- </ToggleButton>- <ToggleButton value="semistrict" data-tid="semiStrictSearchTID">- <TooltipTS title={t('searchTypeSemiStrictTooltip')}>- <div>{t('searchTypeSemiStrict')}</div>- </TooltipTS>- </ToggleButton>- <ToggleButton value="strict" data-tid="strictSearchTID">- <TooltipTS title={t('searchTypeStrictTooltip')}>- <div>{t('searchTypeStrict')}</div>- </TooltipTS>- </ToggleButton>- </ToggleButtonGroup>- </FormControl>- <FormControl- className={classes.formControl}- disabled={isIndexing !== undefined}- >- <ToggleButtonGroup- onChange={() => {- forceIndexing.current = !forceIndexing.current;- forceUpdate();- }}- size="small"- exclusive- style={{ marginBottom: 10, alignSelf: 'center' }}- value={forceIndexing.current}- >- <ToggleButton value={false}>- <TooltipTS title={t('useCurrentIndexTooltip')}>- <div>{t('useCurrentIndex')}</div>- </TooltipTS>- </ToggleButton>- <ToggleButton value={true} data-tid="forceIndexingTID">- <TooltipTS title={t('forceReindexTooltip')}>- <div>{t('forceReindex')}</div>- </TooltipTS>- </ToggleButton>- </ToggleButtonGroup>- </FormControl>- <FormControl- className={classes.formControl}- disabled={isIndexing !== undefined}- >- <TagsSelect- dataTid="searchTagsAndTID"- placeholderText={t('core:selectTags')}- label={t('core:mustContainTheseTags')}- tags={searchQuery.tagsAND}- handleChange={handleTagFieldChange}- tagSearchType="tagsAND"- tagMode="remove"- />- </FormControl>- <FormControl- className={classes.formControl}- disabled={isIndexing !== undefined}- >- <TagsSelect- dataTid="searchTagsOrTID"- placeholderText={t('core:selectTags')}- tags={searchQuery.tagsOR}- label={t('core:atLeastOneOfTheseTags')}- handleChange={handleTagFieldChange}- tagSearchType="tagsOR"- tagMode="remove"- />- </FormControl>- <FormControl- className={classes.formControl}- disabled={isIndexing !== undefined}- >- <TagsSelect- dataTid="searchTagsNotTID"- placeholderText={t('core:selectTags')}- tags={searchQuery.tagsNOT}- label={t('core:noneOfTheseTags')}- handleChange={handleTagFieldChange}- tagSearchType="tagsNOT"- tagMode="remove"- />- </FormControl>- <FormControl- className={classes.formControl}- disabled={isIndexing !== undefined}- >- <TooltipTS title={t('filterByTypTooltip')}>- <FormHelperText style={{ marginLeft: 0 }}>- {t('core:fileType')}- </FormHelperText>- <Select- fullWidth- value={JSON.stringify(fileTypes.current)}- onChange={handleFileTypeChange}- size={desktopMode ? 'small' : 'medium'}- input={<OutlinedInput name="fileTypes" id="file-type" />}- >- <MenuItem value={JSON.stringify(AppConfig.SearchTypeGroups.any)}>- {t('core:anyType')}- </MenuItem>- <MenuItem- value={JSON.stringify(AppConfig.SearchTypeGroups.folders)}- >- <TsIconButton size="small">- <FolderIcon />- </TsIconButton>- {t('core:searchFolders')}- </MenuItem>- <MenuItem- value={JSON.stringify(AppConfig.SearchTypeGroups.files)}- >- <TsIconButton size="small">- <FileIcon />- </TsIconButton>- {t('core:searchFiles')}- </MenuItem>- <MenuItem- value={JSON.stringify(AppConfig.SearchTypeGroups.untagged)}- >- <TsIconButton size="small">- <UntaggedIcon />- </TsIconButton>- {t('core:searchUntaggedEntries')}- </MenuItem>- <MenuItem- value={JSON.stringify(AppConfig.SearchTypeGroups.images)}- title={AppConfig.SearchTypeGroups.images.toString()}- >- <TsIconButton size="small">- <PictureIcon />- </TsIconButton>- {t('core:searchPictures')}- </MenuItem>- <MenuItem- value={JSON.stringify(AppConfig.SearchTypeGroups.documents)}- title={AppConfig.SearchTypeGroups.documents.toString()}- >- <TsIconButton size="small">- <DocumentIcon />- </TsIconButton>- {t('core:searchDocuments')}- </MenuItem>- <MenuItem- value={JSON.stringify(AppConfig.SearchTypeGroups.notes)}- title={AppConfig.SearchTypeGroups.notes.toString()}- >- <TsIconButton size="small">- <NoteIcon />- </TsIconButton>- {t('core:searchNotes')}- </MenuItem>- <MenuItem- value={JSON.stringify(AppConfig.SearchTypeGroups.audio)}- title={AppConfig.SearchTypeGroups.audio.toString()}- >- <TsIconButton size="small">- <AudioIcon />- </TsIconButton>- {t('core:searchAudio')}- </MenuItem>- <MenuItem- value={JSON.stringify(AppConfig.SearchTypeGroups.video)}- title={AppConfig.SearchTypeGroups.video.toString()}- >- <TsIconButton size="small">- <VideoIcon />- </TsIconButton>- {t('core:searchVideoFiles')}- </MenuItem>- <MenuItem- value={JSON.stringify(AppConfig.SearchTypeGroups.archives)}- title={AppConfig.SearchTypeGroups.archives.toString()}- >- <TsIconButton size="small">- <ArchiveIcon />- </TsIconButton>- {t('core:searchArchives')}- </MenuItem>- <MenuItem- value={JSON.stringify(AppConfig.SearchTypeGroups.bookmarks)}- title={AppConfig.SearchTypeGroups.bookmarks.toString()}- >- <TsIconButton size="small">- <BookmarkIcon />- </TsIconButton>- {t('core:searchBookmarks')}- </MenuItem>- <MenuItem- value={JSON.stringify(AppConfig.SearchTypeGroups.ebooks)}- title={AppConfig.SearchTypeGroups.ebooks.toString()}- >- <TsIconButton size="small">- <BookIcon />- </TsIconButton>- {t('core:searchEbooks')}- </MenuItem>- <MenuItem- value={JSON.stringify(AppConfig.SearchTypeGroups.emails)}- title={AppConfig.SearchTypeGroups.emails.toString()}- >- <TsIconButton size="small">- <EmailIcon />- </TsIconButton>- {t('core:searchEmails')}- </MenuItem>- </Select>- </TooltipTS>- </FormControl>- <FormControl- className={classes.formControl}- disabled={isIndexing !== undefined}- >- <TooltipTS title={t('filterBySizeTooltip')}>- <FormHelperText style={{ marginLeft: 0 }}>- {t('core:sizeSearchTitle')}- </FormHelperText>- <Select- fullWidth- value={fileSize.current}- onChange={handleFileSizeChange}- size={desktopMode ? 'small' : 'medium'}- input={<OutlinedInput name="fileSize" id="file-size" />}- displayEmpty- >- <MenuItem value="">{t('core:sizeAny')}</MenuItem>- <MenuItem value="sizeEmpty">{t('core:sizeEmpty')}</MenuItem>- <MenuItem value="sizeTiny">- {t('core:sizeTiny')}- (< 10KB)- </MenuItem>- <MenuItem value="sizeVerySmall">- {t('core:sizeVerySmall')}- (< 100KB)- </MenuItem>- <MenuItem value="sizeSmall">- {t('core:sizeSmall')}- (< 1MB)- </MenuItem>- <MenuItem value="sizeMedium">- {t('core:sizeMedium')}- (< 50MB)- </MenuItem>- <MenuItem value="sizeLarge">- {t('core:sizeLarge')}- (< 1GB)- </MenuItem>- <MenuItem value="sizeHuge">- {t('core:sizeHuge')}- (> 1GB)- </MenuItem>- </Select>- </TooltipTS>- </FormControl>- <FormControl- className={classes.formControl}- disabled={isIndexing !== undefined}- >- <TooltipTS title={t('filterByLastModifiedDateTooltip')}>- <FormHelperText style={{ marginLeft: 0 }}>- {t('core:lastModifiedSearchTitle')}- </FormHelperText>- <Select- fullWidth- value={lastModified.current}- onChange={handleLastModifiedChange}- size={desktopMode ? 'small' : 'medium'}- input={- <OutlinedInput name="lastModified" id="modification-date" />- }- displayEmpty- >- <MenuItem value="">{t('core:anyTime')}</MenuItem>- <MenuItem value="today">{t('core:today')}</MenuItem>- <MenuItem value="yesterday">{t('core:yesterday')}</MenuItem>- <MenuItem value="past7Days">{t('core:past7Days')}</MenuItem>- <MenuItem value="past30Days">{t('core:past30Days')}</MenuItem>- <MenuItem value="past6Months">{t('core:past6Months')}</MenuItem>- <MenuItem value="pastYear">{t('core:pastYear')}</MenuItem>- <MenuItem value="moreThanYear">{t('core:moreThanYear')}</MenuItem>- </Select>- </TooltipTS>- </FormControl>- <FormControl className={classes.formControl}>- <TooltipTS title={t('enterTimePeriodTooltip')}>- <LocalizationProvider dateAdapter={AdapterDateFns}>- <Box position="relative" display="inline-flex">- <div>- <FormHelperText style={{ marginLeft: 0, marginTop: 0 }}>- {t('core:enterTagTimePeriodFrom')}- </FormHelperText>- <DatePicker- disabled={isIndexing !== undefined}- format="yyyy-MM-dd"- value={tagTimePeriodFrom && new Date(tagTimePeriodFrom)}- onChange={(fromDataTime: Date) => {- if (fromDataTime) {- setSearchQuery({- ...searchQuery,- tagTimePeriodFrom: fromDataTime.getTime(),- executeSearch: false,- });- }- }}- />- </div>- <div style={{ marginLeft: 5 }}>- <FormHelperText style={{ marginLeft: 0, marginTop: 0 }}>- {t('core:enterTagTimePeriodTo')}- </FormHelperText>- <DatePicker- disabled={isIndexing !== undefined}- format="yyyy-MM-dd"- value={tagTimePeriodTo && new Date(tagTimePeriodTo)}- onChange={(toDataTime: Date) => {- if (toDataTime) {- setSearchQuery({- ...searchQuery,- tagTimePeriodTo: toDataTime.getTime(),- executeSearch: false,- });- }- }}- />- </div>- </Box>- </LocalizationProvider>- </TooltipTS>- {/* <TsTextField- id="tagPlace"- label={t('GPS coordinates or plus code')}- value={tagPlace}- disabled={indexing || !Pro}- onChange={handlePlaceChange}- onKeyDown={startSearch}- helperText={tagPlaceHelper}- error={tagPlaceHelper.length < 1}- InputProps={{- endAdornment: (- <InputAdornment- position="end"- title="GPS: 49.23276,12.43123 PlusCode: 8FRG8Q87+6X"- >- <IconButton onClick={openPlace}>- <PlaceIcon />- </IconButton>- </InputAdornment>- )- }}- /> */}- </FormControl></div><divstyle={{@@ -1011,7 +229,10 @@ function SearchPopover(props: Props) {variant="contained"disabled={isIndexing !== undefined}id="searchButtonAdvTID"- onClick={executeSearch}+ onClick={() => {+ executeSearch();+ onClose();+ }}>{isIndexing !== undefined? 'Search disabled while indexing'@@ -1019,20 +240,6 @@ function SearchPopover(props: Props) {</TsButton></div></div>- <SaveSearchDialog- open={saveSearchDialogOpened !== undefined}- onClose={(searchQuery: TS.SearchQuery) => {- setSaveSearchDialogOpened(undefined);- if (searchQuery) {- setSearchQuery({- ...searchQuery,- showUnixHiddenEntries,- });- }- }}- onClearSearch={() => clearSearch()}- searchQuery={saveSearchDialogOpened}- /></SidePanel>);}diff --git a/src/renderer/components/StoredSearches.tsx b/src/renderer/components/StoredSearches.tsxindex ae82a63c8..7a70d124b 100644--- a/src/renderer/components/StoredSearches.tsx+++ b/src/renderer/components/StoredSearches.tsx@@ -50,6 +50,7 @@ import RenderHistory from '-/components/RenderHistory';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useSavedSearchesContext } from '-/hooks/useSavedSearchesContext';import SaveSearchDialog from '-/components/dialogs/SaveSearchDialog';+import { useSearchQueryContext } from '-/hooks/useSearchQueryContext';interface Props {style?: any;@@ -69,8 +70,8 @@ interface Props {function StoredSearches(props: Props) {const { t } = useTranslation();- const { setSearchQuery } = useDirectoryContentContext();const { searches, findFromSavedSearch } = useSavedSearchesContext();+ const { openSaveSearchDialog } = useSearchQueryContext();const bookmarksContext = Pro?.contextProviders?.BookmarksContext? useContext<TS.BookmarksContextData>(Pro?.contextProviders?.BookmarksContext,@@ -79,8 +80,6 @@ function StoredSearches(props: Props) {const historyContext = Pro?.contextProviders?.HistoryContext? useContext<TS.HistoryContextData>(Pro.contextProviders.HistoryContext): undefined;- const [saveSearchDialogOpened, setSaveSearchDialogOpened] =- useState<TS.SearchQuery>(undefined);const [searchMenuAnchorEl, setSearchMenuAnchorEl] =useState<null | HTMLElement>(null);const [historyMenuAnchorEl, setHistoryMenuAnchorEl] =@@ -111,14 +110,6 @@ function StoredSearches(props: Props) {setSearchMenuAnchorEl(null);};- const editSearch = (uuid: string) => {- const savedSearch = searches.find((search) => search.uuid === uuid);- if (!savedSearch) {- return true;- }- setSaveSearchDialogOpened(savedSearch);- };-function handleFileInputChange(selection: any) {const target = selection.currentTarget;const file = target.files[0];@@ -276,7 +267,7 @@ function StoredSearches(props: Props) {<Grid item xs={2}><TsIconButtonaria-label={t('core:searchEditBtn')}- onClick={() => editSearch(search.uuid)}+ onClick={() => openSaveSearchDialog(search.uuid)}data-tid="editSearchTID"><EditIcon />@@ -496,20 +487,6 @@ function StoredSearches(props: Props) {update={forceUpdate}/>)}- <SaveSearchDialog- open={saveSearchDialogOpened !== undefined}- onClose={(searchQuery: TS.SearchQuery) => {- setSaveSearchDialogOpened(undefined);- if (searchQuery) {- setSearchQuery({- ...searchQuery,- showUnixHiddenEntries: props.showUnixHiddenEntries,- });- }- }}- onClearSearch={() => console.log('search deleted')}- searchQuery={saveSearchDialogOpened}- /></div><inputstyle={{ display: 'none' }}diff --git a/src/renderer/components/dialogs/SaveSearchDialog.tsx b/src/renderer/components/dialogs/SaveSearchDialog.tsxindex f52cbd327..b160723d1 100644--- a/src/renderer/components/dialogs/SaveSearchDialog.tsx+++ b/src/renderer/components/dialogs/SaveSearchDialog.tsx@@ -35,81 +35,82 @@ import useMediaQuery from '@mui/material/useMediaQuery';import { getUuid } from '@tagspaces/tagspaces-common/utils-io';import { useEffect, useReducer, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';+import { useSearchQueryContext } from '-/hooks/useSearchQueryContext';+import EditSearchQuery from '-/components/EditSearchQuery';interface Props {open: boolean;onClose: (searchQuery?: TS.SearchQuery) => void;- onClearSearch: () => void;- searchQuery: TS.SearchQuery;}function SaveSearchDialog(props: Props) {- const { open, onClose, searchQuery, onClearSearch } = props;+ const { open, onClose } = props;const { searches, addSearch, editSearch, removeSearch } =useSavedSearchesContext();+ const { tempSearchQuery, setTempSearchQuery } = useSearchQueryContext();const theme = useTheme();const smallScreen = useMediaQuery(theme.breakpoints.down('md'));const { t } = useTranslation();- const [inputError, setInputError] = useState<string>('');+ const inputError = useRef<string>(undefined);const title = useRef<string>(getTitle());const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);useEffect(() => {- if (searchQuery) {- if (searchQuery.uuid === undefined) {+ if (tempSearchQuery) {+ title.current = getTitle();+ if (tempSearchQuery.uuid === undefined) {handleValidation();- } else {- title.current = getTitle();- forceUpdate();+ } else if (inputError.current) {+ inputError.current = undefined;}+ forceUpdate();}- }, [searchQuery]);+ }, [tempSearchQuery]);function getTitle() {- return searchQuery && searchQuery.uuid !== undefined- ? searchQuery.title- : defaultTitle(searchQuery);+ return tempSearchQuery && tempSearchQuery.uuid !== undefined+ ? tempSearchQuery.title+ : defaultTitle(tempSearchQuery);}function onDelete() {- removeSearch(searchQuery?.uuid);- onClearSearch();+ removeSearch(tempSearchQuery?.uuid);onClose();}function onConfirm() {if (title.current) {- const searchQuery = {- ...props.searchQuery,- title: title.current,- };+ const searchQuery = setTempSearchQuery({ title: title.current });- if (props.searchQuery.uuid !== undefined) {+ if (searchQuery.uuid !== undefined) {editSearch(searchQuery);onClose();} else {searchQuery.uuid = getUuid();addSearch(searchQuery);- onClose(searchQuery);+ onClose();}}}function handleValidation() {if (!title.current) {- setInputError(t('core:emptyTitle'));+ inputError.current = t('core:emptyTitle');+ forceUpdate();} else if (searches.findIndex((search) => search.title === title.current) > -1) {- setInputError(t('core:duplicateTitle'));- } else if (inputError) {- setInputError('');+ inputError.current = t('core:duplicateTitle');+ forceUpdate();+ } else if (inputError.current) {+ inputError.current = undefined;+ forceUpdate();}}const okButton = (<TsButton- disabled={inputError !== ''}+ disabled={!!inputError.current}onClick={onConfirm}data-tid="confirmSavedSearchTID"variant="contained"@@ -141,7 +142,7 @@ function SaveSearchDialog(props: Props) {><TsDialogTitledialogTitle={t(- searchQuery?.uuid !== undefined+ tempSearchQuery?.uuid !== undefined? 'core:editSavedSearchTitle': 'core:createNewSavedSearchTitle',)}@@ -152,7 +153,7 @@ function SaveSearchDialog(props: Props) {<DialogContent style={{ minWidth: smallScreen ? 'unset' : 300 }}><FormControl fullWidth={true}><TsTextField- error={inputError !== ''}+ error={!!inputError.current}autoFocusname="name"value={title.current}@@ -163,32 +164,41 @@ function SaveSearchDialog(props: Props) {handleValidation();forceUpdate();}}- // updateValue={(value) => {- // title.current = value;- // }}retrieveValue={() => title.current}data-tid="savedSearchTID"/>- <FormHelperText style={{ marginLeft: 0 }} error={inputError !== ''}>- {inputError !== '' ? inputError : t('core:savedSearchHelp')}+ <FormHelperText+ style={{ marginLeft: 0 }}+ error={!!inputError.current}+ >+ {!!inputError.current+ ? inputError.current+ : t('core:savedSearchHelp')}</FormHelperText></FormControl>- {searchQuery?.uuid !== undefined && (- <TsButton- onClick={onDelete}- data-tid="deleteSavedSearchTID"- style={{ marginTop: AppConfig.defaultSpaceBetweenButtons }}- >- {t('core:delete')}- </TsButton>- )}+ <EditSearchQuery /></DialogContent>{!smallScreen && (- <TsDialogActions>- <TsButton data-tid="closeSavedSearchTID" onClick={() => onClose()}>- {t('core:cancel')}- </TsButton>- {okButton}+ <TsDialogActions style={{ justifyContent: 'space-between' }}>+ <div>+ {tempSearchQuery?.uuid !== undefined && (+ <TsButton onClick={onDelete} data-tid="deleteSavedSearchTID">+ {t('core:delete')}+ </TsButton>+ )}+ </div>+ <div>+ <TsButton+ data-tid="closeSavedSearchTID"+ onClick={() => onClose()}+ style={{+ marginRight: AppConfig.defaultSpaceBetweenButtons,+ }}+ >+ {t('core:cancel')}+ </TsButton>+ {okButton}+ </div></TsDialogActions>)}</Dialog>diff --git a/src/renderer/containers/Root.tsx b/src/renderer/containers/Root.tsxindex 66a64c0d7..5278df902 100644--- a/src/renderer/containers/Root.tsx+++ b/src/renderer/containers/Root.tsx@@ -54,6 +54,7 @@ import { BrowserHistoryContextProvider } from '-/hooks/BrowserHistoryContextProvimport { ChatContextProvider } from '-/hooks/ChatProvider';import { FileUploadDialogContextProvider } from '-/components/dialogs/hooks/FileUploadDialogContextProvider';import { EntryPropsTabsContextProvider } from '-/hooks/EntryPropsTabsContextProvider';+import { SearchQueryContextProvider } from '-/hooks/SearchQueryContextProvider';type RootType = {store: Store<{}>;@@ -97,27 +98,29 @@ export default function Root({ store, persistor }: RootType) {<PanelsContextProvider><UserContextProvider><SavedSearchesContextProvider>- <BrowserHistoryContextProvider>- <FileUploadDialogContextProvider>- <ChatContextProvider>- {Pro ? (- <Pro.contextProviders.BookmarksContextProvider>- <Pro.contextProviders.HistoryContextProvider>- <Pro.contextProviders.KanBanImportDialogContextProvider>- <DialogsRoot>- <MainPage />- </DialogsRoot>- </Pro.contextProviders.KanBanImportDialogContextProvider>- </Pro.contextProviders.HistoryContextProvider>- </Pro.contextProviders.BookmarksContextProvider>- ) : (- <DialogsRoot>- <MainPage />- </DialogsRoot>- )}- </ChatContextProvider>- </FileUploadDialogContextProvider>- </BrowserHistoryContextProvider>+ <SearchQueryContextProvider>+ <BrowserHistoryContextProvider>+ <FileUploadDialogContextProvider>+ <ChatContextProvider>+ {Pro ? (+ <Pro.contextProviders.BookmarksContextProvider>+ <Pro.contextProviders.HistoryContextProvider>+ <Pro.contextProviders.KanBanImportDialogContextProvider>+ <DialogsRoot>+ <MainPage />+ </DialogsRoot>+ </Pro.contextProviders.KanBanImportDialogContextProvider>+ </Pro.contextProviders.HistoryContextProvider>+ </Pro.contextProviders.BookmarksContextProvider>+ ) : (+ <DialogsRoot>+ <MainPage />+ </DialogsRoot>+ )}+ </ChatContextProvider>+ </FileUploadDialogContextProvider>+ </BrowserHistoryContextProvider>+ </SearchQueryContextProvider></SavedSearchesContextProvider></UserContextProvider></PanelsContextProvider>diff --git a/src/renderer/hooks/SearchQueryContextProvider.tsx b/src/renderer/hooks/SearchQueryContextProvider.tsxnew file mode 100644index 000000000..bfaabc257--- /dev/null+++ b/src/renderer/hooks/SearchQueryContextProvider.tsx@@ -0,0 +1,172 @@+/*+Copyright (c) 2024-present The TagSpaces GmbH. All rights reserved.+*/++import React, {+ createContext,+ useEffect,+ useMemo,+ useReducer,+ useRef,+ useState,+} from 'react';+import { mergeWithExtractedTags } from '@tagspaces/tagspaces-common/misc';+import { TS } from '-/tagspaces.namespace';+import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';+import SaveSearchDialog from '-/components/dialogs/SaveSearchDialog';+import { useSelector } from 'react-redux';+import { getShowUnixHiddenEntries } from '-/reducers/settings';+import { useSavedSearchesContext } from '-/hooks/useSavedSearchesContext';++type SearchQueryContextData = {+ tempSearchQuery: TS.SearchQuery;+ setTempSearchQuery: (props: any, override?: boolean) => TS.SearchQuery;+ executeSearch: () => void;+ clearSearch: () => void;+ openSaveSearchDialog: (savedSearchUuid?: string) => void;+ closeSaveSearchDialog: () => void;+};++export const SearchQueryContext = createContext<SearchQueryContextData>({+ tempSearchQuery: undefined,+ setTempSearchQuery: undefined,+ executeSearch: undefined,+ clearSearch: undefined,+ openSaveSearchDialog: undefined,+ closeSaveSearchDialog: undefined,+});++export type SearchQueryContextProviderProps = {+ children: React.ReactNode;+};++export const SearchQueryContextProvider = ({+ children,+}: SearchQueryContextProviderProps) => {+ const {+ openCurrentDirectory,+ searchQuery,+ setSearchQuery,+ exitSearchMode,+ currentDirectoryPath,+ } = useDirectoryContentContext();+ const { searches } = useSavedSearchesContext();+ const tempSearchQuery = useRef<TS.SearchQuery>({ ...searchQuery });+ const showUnixHiddenEntries = useSelector(getShowUnixHiddenEntries);+ const [saveSearchDialogOpened, setSaveSearchDialogOpened] =+ useState<boolean>(false);+ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);++ useEffect(() => {+ if (searchQuery) {+ tempSearchQuery.current = { ...searchQuery };+ } else {+ tempSearchQuery.current = {};+ }+ forceUpdate();+ }, [searchQuery]);++ function setTempSearchQuery(props: any, override = false): TS.SearchQuery {+ if (override) {+ tempSearchQuery.current = props;+ } else {+ tempSearchQuery.current = {+ searchBoxing: 'location', // default+ //...searchQuery,+ ...tempSearchQuery.current,+ //executeSearch: false,+ ...props,+ };+ }+ forceUpdate();+ return tempSearchQuery.current;+ }++ function clearSearch() {+ openCurrentDirectory().then(() => {+ tempSearchQuery.current = {}; //...searchQuery };+ setSearchQuery({});+ exitSearchMode();+ });+ }++ function executeSearch() {+ const tagsAND = mergeWithExtractedTags(+ tempSearchQuery.current.textQuery,+ tempSearchQuery.current.tagsAND,+ '+',+ );+ const tagsOR = mergeWithExtractedTags(+ tempSearchQuery.current.textQuery,+ tempSearchQuery.current.tagsOR,+ '|',+ );+ const tagsNOT = mergeWithExtractedTags(+ tempSearchQuery.current.textQuery,+ tempSearchQuery.current.tagsNOT,+ '-',+ );+ const query: TS.SearchQuery = {+ textQuery: tempSearchQuery.current.textQuery,+ tagsAND,+ tagsOR,+ tagsNOT,+ searchBoxing: tempSearchQuery.current.searchBoxing,+ searchType: tempSearchQuery.current.searchType,+ fileTypes: tempSearchQuery.current.fileTypes,+ lastModified: tempSearchQuery.current.lastModified,+ fileSize: tempSearchQuery.current.fileSize,+ tagTimePeriodFrom: tempSearchQuery.current.tagTimePeriodFrom,+ tagTimePeriodTo: tempSearchQuery.current.tagTimePeriodTo,+ // tagPlaceRadius,+ maxSearchResults: tempSearchQuery.current.maxSearchResults,+ currentDirectory: currentDirectoryPath,+ forceIndexing: tempSearchQuery.current.forceIndexing,+ showUnixHiddenEntries,+ executeSearch: true,+ };+ console.log('Search object: ' + JSON.stringify(query));+ setSearchQuery(query);+ }++ function openSaveSearchDialog(savedSearchUuid: string = undefined) {+ if (savedSearchUuid) {+ const savedSearch: TS.SearchQuery = searches.find(+ (search) => search.uuid === savedSearchUuid,+ );+ if (savedSearch) {+ setTempSearchQuery({ ...savedSearch }, true);+ }+ } else {+ setTempSearchQuery({ uuid: undefined });+ }+ setSaveSearchDialogOpened(true);+ }++ function closeSaveSearchDialog() {+ setSaveSearchDialogOpened(false);+ }++ const context = useMemo(() => {+ return {+ tempSearchQuery: tempSearchQuery.current,+ executeSearch: executeSearch,+ clearSearch: clearSearch,+ setTempSearchQuery: setTempSearchQuery,+ openSaveSearchDialog: openSaveSearchDialog,+ closeSaveSearchDialog: closeSaveSearchDialog,+ };+ }, [tempSearchQuery.current]);++ return (+ <SearchQueryContext.Provider value={context}>+ {children}+ <SaveSearchDialog+ open={saveSearchDialogOpened}+ onClose={() => {+ setSaveSearchDialogOpened(false);+ }}+ />+ </SearchQueryContext.Provider>+ );+};diff --git a/src/renderer/hooks/useSearchQueryContext.tsx b/src/renderer/hooks/useSearchQueryContext.tsxnew file mode 100644index 000000000..a5fb2f688--- /dev/null+++ b/src/renderer/hooks/useSearchQueryContext.tsx@@ -0,0 +1,23 @@+/**+ * TagSpaces - universal file and folder organizer+ * Copyright (C) 2024-present TagSpaces GmbH+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License (version 3) as+ * published by the Free Software Foundation.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ */++import { useContext } from 'react';++import { SearchQueryContext } from './SearchQueryContextProvider';++export const useSearchQueryContext = () => useContext(SearchQueryContext);