Skip to content

Commit

Permalink
Add switch for enabling tmb generation on locations (#2061)
Browse files Browse the repository at this point in the history
  • Loading branch information
sytolk committed Feb 23, 2024
1 parent 664a018 commit ffb6b64
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
23 changes: 23 additions & 0 deletions src/renderer/components/dialogs/CreateEditLocationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down Expand Up @@ -376,6 +380,7 @@ function CreateEditLocationDialog(props: Props) {
isDefault,
isReadOnly,
disableIndexing,
disableThumbnailGeneration,
fullTextIndex,
watchForChanges,
maxIndexAge,
Expand All @@ -394,6 +399,7 @@ function CreateEditLocationDialog(props: Props) {
isDefault,
isReadOnly,
disableIndexing,
disableThumbnailGeneration,
fullTextIndex,
watchForChanges,
maxIndexAge,
Expand All @@ -415,6 +421,7 @@ function CreateEditLocationDialog(props: Props) {
isDefault,
isReadOnly,
disableIndexing,
disableThumbnailGeneration,
fullTextIndex,
watchForChanges: false,
maxIndexAge,
Expand Down Expand Up @@ -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"
Expand Down
11 changes: 6 additions & 5 deletions src/renderer/hooks/ThumbGenerationContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -254,7 +255,7 @@ export const ThumbGenerationContextProvider = ({
return {
generateThumbnails,
};
}, []);
}, [currentLocation]);

return (
<ThumbGenerationContext.Provider value={context}>
Expand Down
1 change: 1 addition & 0 deletions src/renderer/locales/en/core.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/renderer/tagspaces.namespace.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export namespace TS {
isNotEditable?: boolean;
watchForChanges?: boolean;
disableIndexing?: boolean;
disableThumbnailGeneration?: boolean;
fullTextIndex?: boolean;
maxIndexAge?: number;
maxLoops?: number;
Expand Down

0 comments on commit ffb6b64

Please sign in to comment.