Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Add switch for enabling tmb generation on locations (#2061)

Stanimirffb6b6477d88
diff --git a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx b/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
index fe0b597d4..630dc9b62 100644
--- a/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
+++ b/src/renderer/components/dialogs/CreateEditLocationDialog.tsx
@@ -177,6 +177,10 @@ function CreateEditLocationDialog(props: Props) {
const [disableIndexing, setIndexDisable] = useState<boolean>(
selectedLocation ? selectedLocation.disableIndexing : false,
);
+ const [disableThumbnailGeneration, setDisableThumbnailGeneration] =
+ useState<boolean>(
+ selectedLocation ? selectedLocation.disableThumbnailGeneration : false,
+ );
const [fullTextIndex, setFullTextIndex] = useState<boolean>(
selectedLocation ? selectedLocation.fullTextIndex : false,
);
@@ -376,6 +380,7 @@ function CreateEditLocationDialog(props: Props) {
isDefault,
isReadOnly,
disableIndexing,
+ disableThumbnailGeneration,
fullTextIndex,
watchForChanges,
maxIndexAge,
@@ -394,6 +399,7 @@ function CreateEditLocationDialog(props: Props) {
isDefault,
isReadOnly,
disableIndexing,
+ disableThumbnailGeneration,
fullTextIndex,
watchForChanges,
maxIndexAge,
@@ -415,6 +421,7 @@ function CreateEditLocationDialog(props: Props) {
isDefault,
isReadOnly,
disableIndexing,
+ disableThumbnailGeneration,
fullTextIndex,
watchForChanges: false,
maxIndexAge,
@@ -745,6 +752,22 @@ function CreateEditLocationDialog(props: Props) {
</>
}
/>
+ <FormControlLabel
+ className={classes.formControl}
+ labelPlacement="start"
+ style={{ justifyContent: 'space-between' }}
+ control={
+ <Switch
+ data-tid="locationSettingsGenThumbsTID"
+ name="locationSettingsGenThumbs"
+ checked={disableThumbnailGeneration}
+ onChange={(event: ChangeEvent<HTMLInputElement>) =>
+ setDisableThumbnailGeneration(event.target.checked)
+ }
+ />
+ }
+ label={<>{t('core:disableThumbnailGeneration')}</>}
+ />
<FormControlLabel
className={classes.formControl}
labelPlacement="start"
diff --git a/src/renderer/hooks/ThumbGenerationContextProvider.tsx b/src/renderer/hooks/ThumbGenerationContextProvider.tsx
index f705d4b54..dc5125266 100644
--- a/src/renderer/hooks/ThumbGenerationContextProvider.tsx
+++ b/src/renderer/hooks/ThumbGenerationContextProvider.tsx
@@ -38,6 +38,7 @@ import { usePaginationContext } from '-/hooks/usePaginationContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
import { loadCurrentDirMeta } from '-/services/meta-loader';
+import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
type ThumbGenerationContextData = {
generateThumbnails: (dirEntries: TS.FileSystemEntry[]) => Promise<boolean>;
@@ -61,7 +62,7 @@ export const ThumbGenerationContextProvider = ({
currentDirectoryEntries,
updateCurrentDirEntries,
} = useDirectoryContentContext();
- //const { currentLocation } = useCurrentLocationContext();
+ const { currentLocation } = useCurrentLocationContext();
const { pageFiles, page } = usePaginationContext();
const { setGeneratingThumbs } = useNotificationContext();
const useGenerateThumbnails = useSelector(getUseGenerateThumbnails);
@@ -128,9 +129,9 @@ export const ThumbGenerationContextProvider = ({
) {
return false; // dont generate thumbnails in meta folder
}
- /*if (currentLocation.type === locationType.TYPE_CLOUD) {
- return false; // dont generate thumbnails for cloud location
- }*/
+ if (currentLocation?.disableThumbnailGeneration === true) {
+ return false; // dont generate thumbnails if it's not enabled in location settings
+ }
if (AppConfig.useGenerateThumbnails !== undefined) {
return AppConfig.useGenerateThumbnails;
}
@@ -254,7 +255,7 @@ export const ThumbGenerationContextProvider = ({
return {
generateThumbnails,
};
- }, []);
+ }, [currentLocation]);
return (
<ThumbGenerationContext.Provider value={context}>
diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.json
index eb305c7ca..e47320674 100644
--- a/src/renderer/locales/en/core.json
+++ b/src/renderer/locales/en/core.json
@@ -392,6 +392,7 @@
"readonlyModeSwitch": "Open this location in read-only mode",
"persistIndexSwitch": "Switch to manual index creation with persisted search index",
"disableIndexing": "Disable Indexing",
+ "disableThumbnailGeneration": "Disable Thumbnail Generation",
"createFullTextIndex": "Enable full text search for TXT, MD and HTML files",
"watchForChangesInLocation": "Watch for external changes in this location",
"collectedTags": "Collected Tags",
diff --git a/src/renderer/tagspaces.namespace.d.ts b/src/renderer/tagspaces.namespace.d.ts
index 867fba37b..27c06b054 100644
--- a/src/renderer/tagspaces.namespace.d.ts
+++ b/src/renderer/tagspaces.namespace.d.ts
@@ -41,6 +41,7 @@ export namespace TS {
isNotEditable?: boolean;
watchForChanges?: boolean;
disableIndexing?: boolean;
+ disableThumbnailGeneration?: boolean;
fullTextIndex?: boolean;
maxIndexAge?: number;
maxLoops?: number;