TagSpaces is an offline, open source, document manager with tagging support
Added maxIndexAge property for the locations (#1400)
Stanimir94d2807d536b
diff --git a/app/components/dialogs/CreateEditLocationDialog.tsx b/app/components/dialogs/CreateEditLocationDialog.tsxindex 6abfac94d..423878d3e 100644--- a/app/components/dialogs/CreateEditLocationDialog.tsx+++ b/app/components/dialogs/CreateEditLocationDialog.tsx@@ -31,8 +31,9 @@ import FormGroup from '@material-ui/core/FormGroup';import Grid from '@material-ui/core/Grid';import Radio from '@material-ui/core/Radio';import RadioGroup from '@material-ui/core/RadioGroup';-import { Typography } from '@material-ui/core';+import { Tooltip, Typography } from '@material-ui/core';import Dialog from '@material-ui/core/Dialog';+import Input from '@material-ui/core/Input';import i18n from '-/services/i18n';import { Location, locationType } from '-/reducers/locations';import { Pro } from '-/pro';@@ -75,6 +76,12 @@ const CreateEditLocationDialog = (props: Props) => {const [name, setName] = useState<string>(location && location.name ? location.name : '');+ let defaultIndexAge = AppConfig.maxIndexAge;+ if (location && location.maxIndexAge && location.maxIndexAge > 0) {+ const maxIndexAsString = location.maxIndexAge + '';+ defaultIndexAge = parseInt(maxIndexAsString, 10);+ }+ const [maxIndexAge, setMaxIndexAge] = useState<number>(defaultIndexAge);const [storeName, setStoreName] = useState<string>(location && location.name ? location.name : '');@@ -139,6 +146,13 @@ const CreateEditLocationDialog = (props: Props) => {const firstRender = useFirstRender();+ function changeMaxIndexAge(ageInMinutes) {+ if (ageInMinutes) {+ const age = parseInt(ageInMinutes, 10);+ setMaxIndexAge(age * 1000 * 60);+ }+ }+useEffect(() => {if (!firstRender) {validateObjectStore();@@ -227,7 +241,8 @@ const CreateEditLocationDialog = (props: Props) => {isReadOnly,persistIndex,fullTextIndex,- watchForChanges+ watchForChanges,+ maxIndexAge};} else if (type === locationType.TYPE_CLOUD) {loc = {@@ -246,7 +261,8 @@ const CreateEditLocationDialog = (props: Props) => {isReadOnly,persistIndex,fullTextIndex,- watchForChanges: false+ watchForChanges: false,+ maxIndexAge};}@@ -459,6 +475,28 @@ const CreateEditLocationDialog = (props: Props) => {}/>)}+ {showAdvancedMode && (+ <FormControlLabel+ control={+ <Tooltip title={i18n.t('core:maxIndexAgeHelp')}>+ <Input+ name="maxIndexAge"+ style={{+ maxWidth: 70,+ marginLeft: 15,+ marginRight: 15+ }}+ type="number"+ data-tid="maxIndexAgeTID"+ inputProps={{ min: 0 }}+ value={maxIndexAge / (1000 * 60)}+ onChange={event => changeMaxIndexAge(event.target.value)}+ />+ </Tooltip>+ }+ label={i18n.t('core:maxIndexAge')}+ />+ )}</FormGroup></DialogContent><DialogActions style={{ justifyContent: 'space-between' }}>diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex 23da18170..4b6c64084 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -530,5 +530,7 @@"TOTPEnabled": "TOTP Is Enabled","disableTOTP": "disable TOTP","confirmResetColor": "Do you really want to clear this color?",+ "maxIndexAge": "Index validity duration in minutes",+ "maxIndexAgeHelp": "After this time the search index will be invalidated","-": "-"}diff --git a/app/reducers/location-index.ts b/app/reducers/location-index.tsindex 3011f5227..99ce6af74 100644--- a/app/reducers/location-index.ts+++ b/app/reducers/location-index.ts@@ -319,10 +319,13 @@ export const actions = {const indexAge = GlobalSearch.indexLoadedOn? currentTime - GlobalSearch.indexLoadedOn: 0;+ const maxIndexAge = currentLocation.maxIndexAge+ ? currentLocation.maxIndexAge+ : AppConfig.maxIndexAge;if (GlobalSearch.index.length < 1 ||searchQuery.forceIndexing ||- indexAge > AppConfig.maxIndexAge+ indexAge > maxIndexAge) {const currentPath = getLocationPath(currentLocation);console.log('Start creating index for : ' + currentPath);diff --git a/app/reducers/locations.ts b/app/reducers/locations.tsindex cc39fc35b..bcdf34999 100644--- a/app/reducers/locations.ts+++ b/app/reducers/locations.ts@@ -59,6 +59,7 @@ export type Location = {watchForChanges?: boolean;persistIndex?: boolean;fullTextIndex?: boolean;+ maxIndexAge?: number;};export const initialState = [];