Skip to content

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

write custo perspectiveSetting per folder (#1707)

Stanimir126ad5ff70a0
diff --git a/app/components/LocationView.tsx b/app/components/LocationView.tsx
index 635fccd06..eea947b88 100644
--- a/app/components/LocationView.tsx
+++ b/app/components/LocationView.tsx
@@ -111,7 +111,7 @@ function LocationView(props: Props) {
const handleLocationClick = () => {
if (location.uuid === props.currentLocationId) {
// the same location click
- props.loadDirectoryContent(PlatformIO.getLocationPath(location), true); // false);
+ props.loadDirectoryContent(PlatformIO.getLocationPath(location), true, true);
} else {
// this.directoryTreeRef[location.uuid].loadSubDir(location, 1);
props.setSelectedEntries([]);
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index dda4ef887..381941e01 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -655,6 +655,13 @@
"WebdavAuth": "WebDAV authorization type",
"selectedFiles": "Selected files",
"selectedFilesAndFolders": "Selected files and folders",
+ "defaultSettings": "Set as default",
+ "directorySettings": "Set for this folder",
+ "byName": "By Name",
+ "byFileSize": "By File Size",
+ "byDateModified": "By Date Modified",
+ "byFirstTag": "By First Tag",
+ "byExtension": "By Extension",
"rename": "Rename",
"-": "-"
}
diff --git a/app/package.json b/app/package.json
index 84d7e4905..95b4815c5 100644
--- a/app/package.json
+++ b/app/package.json
@@ -16,7 +16,7 @@
"@tagspaces/extensions": "1.0.30"
},
"nodeDependencies": {
- "@tagspaces/tagspaces-ws": "2.0.13",
+ "@tagspaces/tagspaces-ws": "2.0.15",
"@tagspaces/extensions": "1.0.30",
"sharp": "^0.30.7"
}
diff --git a/app/perspectives/grid-perspective/components/GridOptionsMenu.tsx b/app/perspectives/grid-perspective/components/GridOptionsMenu.tsx
index c73193a38..6628b8c6d 100644
--- a/app/perspectives/grid-perspective/components/GridOptionsMenu.tsx
+++ b/app/perspectives/grid-perspective/components/GridOptionsMenu.tsx
@@ -40,7 +40,7 @@ interface Props {
toggleShowTags: () => void;
showDirectories: boolean;
showTags: boolean;
- toggleThumbnailsMode: () => void;
+ toggleThumbnailsMode: () => string;
thumbnailMode: string;
singleClickAction: string;
entrySize: string;
diff --git a/app/perspectives/grid-perspective/components/GridPagination.tsx b/app/perspectives/grid-perspective/components/GridPagination.tsx
index 42bf0c52a..2a9ac2188 100644
--- a/app/perspectives/grid-perspective/components/GridPagination.tsx
+++ b/app/perspectives/grid-perspective/components/GridPagination.tsx
@@ -152,7 +152,7 @@ function GridPagination(props: Props) {
PlatformIO.getDirSeparator(),
false
);
- if (meta.some(metaFile => thumbPath.endsWith(metaFile.path))) {
+ if (thumbPath && meta.some(metaFile => thumbPath.endsWith(metaFile.path))) {
thumbEntry.thumbPath = thumbPath;
if (
PlatformIO.haveObjectStoreSupport() ||
diff --git a/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx b/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx
index 1377916ee..f53a94e56 100644
--- a/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx
+++ b/app/perspectives/grid-perspective/components/GridSettingsDialog.tsx
@@ -16,7 +16,7 @@
*
*/
-import React from 'react';
+import React, { useReducer, useRef } from 'react';
import {
Dialog,
DialogActions,
@@ -42,6 +42,7 @@ import RadioUncheckedIcon from '@mui/icons-material/RadioButtonUnchecked';
import withStyles from '@mui/styles/withStyles';
import DialogCloseButton from '-/components/dialogs/DialogCloseButton';
import i18n from '-/services/i18n';
+import { Pro } from '-/pro';
const styles: any = {
root: {
@@ -63,24 +64,31 @@ const styles: any = {
interface Props {
open: boolean;
gridPageLimit: number;
- onClose: () => void;
+ onClose: (isDefault?: boolean) => void;
setGridPageLimit: (number) => void;
toggleShowDirectories: () => void;
toggleShowTags: () => void;
showDirectories: boolean;
showTags: boolean;
- toggleThumbnailsMode: () => void;
+ toggleThumbnailsMode: () => string;
thumbnailMode: string;
changeEntrySize: (entrySize: string) => void;
entrySize: string;
changeSingleClickAction: (actionType: string) => void;
singleClickAction: string;
openHelpWebPage: () => void;
+ sortBy: string;
+ orderBy: boolean;
+ handleSortingMenu: (event) => void;
classes: any;
// setShowDirectories: (check: boolean) => void;
}
function GridSettingsDialog(props: Props) {
+ const [ignored, forceUpdate] = useReducer(x => x + 1, 0);
+ const thumbnailMode = useRef<string>(props.thumbnailMode);
+ const entrySize = useRef<string>(props.entrySize);
+ const singleClickAction = useRef<string>(props.singleClickAction);
const {
open,
onClose,
@@ -90,11 +98,8 @@ function GridSettingsDialog(props: Props) {
toggleShowTags,
showTags,
toggleThumbnailsMode,
- thumbnailMode,
changeEntrySize,
- entrySize,
changeSingleClickAction,
- singleClickAction,
openHelpWebPage
} = props;
@@ -121,10 +126,10 @@ function GridSettingsDialog(props: Props) {
}
return (
- <Dialog open={open} onClose={onClose} keepMounted scroll="paper">
+ <Dialog open={open} onClose={() => onClose()} keepMounted scroll="paper">
<DialogTitle>
{i18n.t('core:perspectiveSettingsTitle')}
- <DialogCloseButton onClose={onClose} />
+ <DialogCloseButton onClose={() => onClose()} />
</DialogTitle>
<DialogContent>
<FormGroup>
@@ -132,7 +137,7 @@ function GridSettingsDialog(props: Props) {
control={
<Switch
data-tid="gridPerspectiveToggleShowDirectories"
- checked={showDirectories}
+ defaultChecked={showDirectories}
onChange={toggleShowDirectories}
name="checkedB"
color="primary"
@@ -144,7 +149,7 @@ function GridSettingsDialog(props: Props) {
control={
<Switch
data-tid="gridPerspectiveToggleShowTags"
- checked={showTags}
+ defaultChecked={showTags}
onChange={toggleShowTags}
name="checkedB"
color="primary"
@@ -158,10 +163,13 @@ function GridSettingsDialog(props: Props) {
data-tid="gridPerspectiveToggleThumbnailsMode"
title={i18n.t('core:toggleThumbnailModeTitle')}
aria-label={i18n.t('core:toggleThumbnailMode')}
- onClick={toggleThumbnailsMode}
+ onClick={() => {
+ thumbnailMode.current = toggleThumbnailsMode();
+ forceUpdate();
+ }}
>
<ListItemIcon>
- {thumbnailMode === 'cover' ? (
+ {thumbnailMode.current === 'cover' ? (
<ThumbnailCoverIcon />
) : (
<ThumbnailContainIcon />
@@ -170,14 +178,37 @@ function GridSettingsDialog(props: Props) {
<ListItemText primary={i18n.t('core:toggleThumbnailMode')} />
</MenuItem>
<Divider />
+ <MenuItem
+ data-tid="sortByMenuTID"
+ title={i18n.t('core:sortBy')}
+ aria-label={i18n.t('core:sortBy')}
+ onClick={e => {
+ props.handleSortingMenu(e);
+ }}
+ >
+ <ListItemText
+ primary={
+ i18n.t('core:sort') +
+ ': ' +
+ i18n.t(props.sortBy) +
+ ' ' +
+ (props.orderBy ? 'ASC' : 'DESC')
+ }
+ />
+ </MenuItem>
+ <Divider />
<MenuItem
data-tid="gridPerspectiveEntrySizeSmall"
title={i18n.t('core:entrySizeSmall')}
aria-label={i18n.t('core:entrySizeSmall')}
- onClick={() => changeEntrySize('small')}
+ onClick={() => {
+ changeEntrySize('small');
+ entrySize.current = 'small';
+ forceUpdate();
+ }}
>
<ListItemIcon>
- {entrySize === 'small' ? (
+ {entrySize.current === 'small' ? (
<RadioCheckedIcon />
) : (
<RadioUncheckedIcon />
@@ -189,10 +220,14 @@ function GridSettingsDialog(props: Props) {
data-tid="gridPerspectiveEntrySizeNormal"
title={i18n.t('core:entrySizeNormal')}
aria-label={i18n.t('core:entrySizeNormal')}
- onClick={() => changeEntrySize('normal')}
+ onClick={() => {
+ changeEntrySize('normal');
+ entrySize.current = 'normal';
+ forceUpdate();
+ }}
>
<ListItemIcon>
- {entrySize === 'normal' ? (
+ {entrySize.current === 'normal' ? (
<RadioCheckedIcon />
) : (
<RadioUncheckedIcon />
@@ -204,10 +239,14 @@ function GridSettingsDialog(props: Props) {
data-tid="gridPerspectiveEntrySizeBig"
title={i18n.t('core:entrySizeBig')}
aria-label={i18n.t('core:entrySizeBig')}
- onClick={() => changeEntrySize('big')}
+ onClick={() => {
+ changeEntrySize('big');
+ entrySize.current = 'big';
+ forceUpdate();
+ }}
>
<ListItemIcon>
- {entrySize === 'big' ? (
+ {entrySize.current === 'big' ? (
<RadioCheckedIcon />
) : (
<RadioUncheckedIcon />
@@ -220,10 +259,14 @@ function GridSettingsDialog(props: Props) {
data-tid="gridPerspectiveSingleClickOpenInternally"
title={i18n.t('core:singleClickOpenInternally')}
aria-label={i18n.t('core:singleClickOpenInternally')}
- onClick={() => changeSingleClickAction('openInternal')}
+ onClick={() => {
+ changeSingleClickAction('openInternal');
+ singleClickAction.current = 'openInternal';
+ forceUpdate();
+ }}
>
<ListItemIcon>
- {singleClickAction === 'openInternal' ? (
+ {singleClickAction.current === 'openInternal' ? (
<RadioCheckedIcon />
) : (
<RadioUncheckedIcon />
@@ -235,10 +278,14 @@ function GridSettingsDialog(props: Props) {
data-tid="gridPerspectiveSingleClickOpenExternally"
title={i18n.t('core:singleClickOpenExternally')}
aria-label={i18n.t('core:singleClickOpenExternally')}
- onClick={() => changeSingleClickAction('openExternal')}
+ onClick={() => {
+ changeSingleClickAction('openExternal');
+ singleClickAction.current = 'openExternal';
+ forceUpdate();
+ }}
>
<ListItemIcon>
- {singleClickAction === 'openExternal' ? (
+ {singleClickAction.current === 'openExternal' ? (
<RadioCheckedIcon />
) : (
<RadioUncheckedIcon />
@@ -250,10 +297,14 @@ function GridSettingsDialog(props: Props) {
data-tid="gridPerspectiveSingleClickSelects"
title={i18n.t('core:singleClickSelects')}
aria-label={i18n.t('core:singleClickSelects')}
- onClick={() => changeSingleClickAction('selects')}
+ onClick={() => {
+ changeSingleClickAction('selects');
+ singleClickAction.current = 'selects';
+ forceUpdate();
+ }}
>
<ListItemIcon>
- {singleClickAction === 'selects' ? (
+ {singleClickAction.current === 'selects' ? (
<RadioCheckedIcon />
) : (
<RadioUncheckedIcon />
@@ -292,13 +343,27 @@ function GridSettingsDialog(props: Props) {
{i18n.t('core:help')}
</Button>
<Button
- data-tid="cancelDialog"
- title={i18n.t('core:closeButton')}
- onClick={onClose}
+ data-tid="defaultSettings"
+ title={i18n.t('core:defaultSettings')}
+ onClick={() => {
+ onClose(true);
+ }}
color="primary"
>
- {i18n.t('core:closeButton')}
+ {i18n.t('core:defaultSettings')}
</Button>
+ {Pro && (
+ <Button
+ data-tid="directorySettings"
+ title={i18n.t('core:directorySettings')}
+ onClick={() => {
+ onClose(false);
+ }}
+ color="primary"
+ >
+ {i18n.t('core:directorySettings')}
+ </Button>
+ )}
</DialogActions>
</Dialog>
);
diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsx
index 140a68447..18abd2bcc 100644
--- a/app/perspectives/grid-perspective/components/MainContainer.tsx
+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx
@@ -16,7 +16,7 @@
*
*/
-import React, { useEffect, useMemo, useRef, useState } from 'react';
+import React, { useEffect, useMemo, useReducer, useRef, useState } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { GlobalHotKeys } from 'react-hotkeys';
@@ -49,6 +49,7 @@ import TagDropContainer from '-/components/TagDropContainer';
import IOActions from '-/reducers/io-actions';
import {
actions as AppActions,
+ getDirectoryMeta,
getLastSelectedEntry,
getSelectedEntries,
isDeleteMultipleEntriesDialogOpened,
@@ -68,6 +69,7 @@ import { TS } from '-/tagspaces.namespace';
import { Pro } from '-/pro';
import Links from '-/links';
import { defaultSettings } from '../index';
+import { PerspectiveIDs } from '-/perspectives';
interface Props {
classes: any;
@@ -109,10 +111,25 @@ interface Props {
locations: Array<TS.Location>;
// isDesktopMode: boolean;
toggleDeleteMultipleEntriesDialog: () => void;
+ directoryMeta: TS.FileSystemEntryMeta;
+ setDirectoryMeta: (fsEntryMeta: TS.FileSystemEntryMeta) => void;
+}
+
+function getSettings(directoryMeta: TS.FileSystemEntryMeta) {
+ if (
+ directoryMeta &&
+ directoryMeta.perspectiveSettings &&
+ directoryMeta.perspectiveSettings[PerspectiveIDs.GRID]
+ ) {
+ return directoryMeta.perspectiveSettings[PerspectiveIDs.GRID];
+ } else {
+ // loading settings for not Pro
+ return JSON.parse(localStorage.getItem(defaultSettings.settingsKey));
+ }
}
function GridPerspective(props: Props) {
- let settings = JSON.parse(localStorage.getItem(defaultSettings.settingsKey)); // loading settings
+ const settings = getSettings(props.directoryMeta);
const [mouseX, setMouseX] = useState<number>(undefined);
const [mouseY, setMouseY] = useState<number>(undefined);
@@ -142,41 +159,40 @@ function GridPerspective(props: Props) {
const [isAddTagDialogOpened, setIsAddTagDialogOpened] = useState<TS.Tag>(
undefined
);
- const [sortBy, setSortBy] = useState<string>(
+ const sortBy = useRef<string>(
settings && settings.sortBy ? settings.sortBy : defaultSettings.sortBy
);
- const [orderBy, setOrderBy] = useState<null | boolean>(
+ const orderBy = useRef<null | boolean>(
settings && typeof settings.orderBy !== 'undefined'
? settings.orderBy
: defaultSettings.orderBy
);
- // const [layoutType, setLayoutType] = useState<string>(
- // settings && settings.layoutType
- // ? settings.layoutType
- // : defaultSettings.layoutType
- // );
- const [layoutType, setLayoutType] = useState<string>('grid');
- const [singleClickAction, setSingleClickAction] = useState<string>(
+ const layoutType = useRef<string>(
+ settings && settings.layoutType
+ ? settings.layoutType
+ : defaultSettings.layoutType
+ );
+ const singleClickAction = useRef<string>(
settings && settings.singleClickAction
? settings.singleClickAction
: defaultSettings.singleClickAction
);
- const [entrySize, setEntrySize] = useState<string>(
+ const entrySize = useRef<string>(
settings && settings.entrySize
? settings.entrySize
: defaultSettings.entrySize
);
- const [thumbnailMode, setThumbnailMode] = useState<string>(
+ const thumbnailMode = useRef<string>(
settings && settings.thumbnailMode
? settings.thumbnailMode
: defaultSettings.thumbnailMode
);
- const [showDirectories, setShowDirectories] = useState<boolean>(
+ const showDirectories = useRef<boolean>(
settings && typeof settings.showDirectories !== 'undefined'
? settings.showDirectories
: defaultSettings.showDirectories
);
- const [showTags, setShowTags] = useState<boolean>(
+ const showTags = useRef<boolean>(
settings && typeof settings.showTags !== 'undefined'
? settings.showTags
: defaultSettings.showTags
@@ -192,38 +208,98 @@ function GridPerspective(props: Props) {
const [isGridSettingsDialogOpened, setIsGridSettingsDialogOpened] = useState<
boolean
>(false);
- const [gridPageLimit, setGridPageLimit] = useState<number>(
- settings && settings.gridPageLimit ? settings.gridPageLimit : 100
+ const gridPageLimit = useRef<number>(
+ settings && settings.gridPageLimit
+ ? settings.gridPageLimit
+ : defaultSettings.gridPageLimit
);
+ // true: save in default settings; false: save per folder settings; undefined - dont save changes
+ const isDefaultSetting = useRef<boolean>(undefined);
+ const [ignored, forceUpdate] = useReducer(x => x + 1, 0);
useEffect(() => {
makeFirstSelectedEntryVisible();
}, [props.selectedEntries]);
- settings = {
- showDirectories,
- showTags,
- layoutType,
- orderBy,
- sortBy,
- singleClickAction,
- entrySize,
- thumbnailMode,
- gridPageLimit
- };
+ useEffect(() => {
+ const perspectiveSettings = getSettings(props.directoryMeta);
+ showDirectories.current =
+ perspectiveSettings && perspectiveSettings.showDirectories !== undefined
+ ? perspectiveSettings.showDirectories
+ : defaultSettings.showDirectories;
+ showTags.current =
+ perspectiveSettings && perspectiveSettings.showTags !== undefined
+ ? perspectiveSettings.showTags
+ : defaultSettings.showTags;
+ layoutType.current = defaultSettings.layoutType;
+ orderBy.current =
+ perspectiveSettings && perspectiveSettings.orderBy !== undefined
+ ? perspectiveSettings.orderBy
+ : defaultSettings.orderBy;
+ sortBy.current =
+ perspectiveSettings && perspectiveSettings.sortBy !== undefined
+ ? perspectiveSettings.sortBy
+ : defaultSettings.sortBy;
+ singleClickAction.current =
+ perspectiveSettings && perspectiveSettings.singleClickAction !== undefined
+ ? perspectiveSettings.singleClickAction
+ : defaultSettings.singleClickAction;
+ entrySize.current =
+ perspectiveSettings && perspectiveSettings.entrySize !== undefined
+ ? perspectiveSettings.entrySize
+ : defaultSettings.entrySize;
+ thumbnailMode.current =
+ perspectiveSettings && perspectiveSettings.thumbnailMode !== undefined
+ ? perspectiveSettings.thumbnailMode
+ : defaultSettings.thumbnailMode;
+ gridPageLimit.current =
+ perspectiveSettings && perspectiveSettings.gridPageLimit !== undefined
+ ? perspectiveSettings.gridPageLimit
+ : defaultSettings.gridPageLimit;
+ forceUpdate();
+ }, [props.directoryMeta]);
useEffect(() => {
- localStorage.setItem(defaultSettings.settingsKey, JSON.stringify(settings));
+ if (isDefaultSetting.current !== undefined) {
+ const perspectiveSettings = {
+ showDirectories: showDirectories.current,
+ showTags: showTags.current,
+ layoutType: layoutType.current,
+ orderBy: orderBy.current,
+ sortBy: sortBy.current,
+ singleClickAction: singleClickAction.current,
+ entrySize: entrySize.current,
+ thumbnailMode: thumbnailMode.current,
+ gridPageLimit: gridPageLimit.current
+ };
+ if (Pro && !isDefaultSetting.current) {
+ Pro.MetaOperations.savePerspectiveSettings(
+ currentDirectoryPath,
+ PerspectiveIDs.GRID,
+ perspectiveSettings
+ ).then((fsEntryMeta: TS.FileSystemEntryMeta) => {
+ props.setDirectoryMeta(fsEntryMeta);
+ });
+ } else {
+ localStorage.setItem(
+ defaultSettings.settingsKey,
+ JSON.stringify(perspectiveSettings)
+ );
+ forceUpdate();
+ }
+ isDefaultSetting.current = undefined;
+ }
}, [
- showDirectories,
- showTags,
- layoutType,
- orderBy,
- sortBy,
- singleClickAction,
- entrySize,
- thumbnailMode,
- gridPageLimit
+ isDefaultSetting.current,
+ showDirectories.current,
+ showTags.current,
+ layoutType.current,
+ orderBy.current,
+ sortBy.current,
+ singleClickAction.current,
+ entrySize.current,
+ thumbnailMode.current,
+ gridPageLimit.current
]);
const fileOperationsEnabled = () => {
@@ -246,8 +322,9 @@ function GridPerspective(props: Props) {
};
const sortedDirContentMemoized = useMemo(
- () => sortByCriteria(props.directoryContent, sortBy, orderBy),
- [props.directoryContent, sortBy, orderBy]
+ () =>
+ sortByCriteria(props.directoryContent, sortBy.current, orderBy.current),
+ [props.directoryContent, sortBy.current, orderBy.current]
);
const makeFirstSelectedEntryVisible = () => {
@@ -266,24 +343,27 @@ function GridPerspective(props: Props) {
};
const handleLayoutSwitch = (type: string) => {
- setLayoutType(type);
+ layoutType.current = type;
+ // forceUpdate();
};
const handleGridPageLimit = (limit: number) => {
- setGridPageLimit(limit);
- setIsGridSettingsDialogOpened(false);
+ gridPageLimit.current = limit;
+ // setIsGridSettingsDialogOpened(false);
+ // forceUpdate();
};
const handleSortBy = handleSort => {
- if (sortBy !== handleSort) {
- setSortBy(handleSort);
+ if (sortBy.current !== handleSort) {
+ sortBy.current = handleSort;
} else {
- setOrderBy(!orderBy);
+ orderBy.current = !orderBy.current;
}
+ // forceUpdate();
setSortingContextMenuAnchorEl(null);
};
- const handleSortingMenu = event => {
+ const handleSortingMenu = (event) => {
const anchor = event ? event.currentTarget : null;
setSortingContextMenuAnchorEl(anchor);
};
@@ -346,9 +426,9 @@ function GridPerspective(props: Props) {
} else {
setSelectedEntries([fsEntry]);
if (fsEntry.isFile) {
- if (singleClickAction === 'openInternal') {
+ if (singleClickAction.current === 'openInternal') {
props.openFsEntry(fsEntry);
- } else if (singleClickAction === 'openExternal') {
+ } else if (singleClickAction.current === 'openExternal') {
props.openFileNatively(fsEntry.path);
}
}
@@ -380,28 +460,34 @@ function GridPerspective(props: Props) {
const toggleShowDirectories = () => {
closeOptionsMenu();
- setShowDirectories(!showDirectories);
+ showDirectories.current = !showDirectories.current;
+ // forceUpdate();
};
const toggleShowTags = () => {
closeOptionsMenu();
- setShowTags(!showTags);
+ showTags.current = !showTags.current;
+ // forceUpdate();
};
const toggleThumbnailsMode = () => {
closeOptionsMenu();
- const thumbMode = thumbnailMode === 'cover' ? 'contain' : 'cover';
- setThumbnailMode(thumbMode);
+ const thumbMode = thumbnailMode.current === 'cover' ? 'contain' : 'cover';
+ thumbnailMode.current = thumbMode;
+ // forceUpdate();
+ return thumbMode;
};
const changeEntrySize = size => {
closeOptionsMenu();
- setEntrySize(size);
+ entrySize.current = size;
+ // forceUpdate();
};
const changeSingleClickAction = singleClick => {
closeOptionsMenu();
- setSingleClickAction(singleClick);
+ singleClickAction.current = singleClick;
+ // forceUpdate();
};
const openHelpWebPage = () => {
@@ -581,7 +667,7 @@ function GridPerspective(props: Props) {
supportedFileTypes,
openFsEntry
} = props;
- if (!fsEntry.isFile && !showDirectories) {
+ if (!fsEntry.isFile && !showDirectories.current) {
return;
}
@@ -603,12 +689,12 @@ function GridPerspective(props: Props) {
<CellContent
selected={selected}
fsEntry={fsEntry}
- entrySize={entrySize}
+ entrySize={entrySize.current}
classes={classes}
isLast={isLast}
theme={theme}
supportedFileTypes={supportedFileTypes}
- thumbnailMode={thumbnailMode}
+ thumbnailMode={thumbnailMode.current}
addTags={addTags}
addTag={addTag}
selectedEntries={selectedEntries}
@@ -616,8 +702,8 @@ function GridPerspective(props: Props) {
deselectEntry={deselectEntry}
isReadOnlyMode={props.isReadOnlyMode}
handleTagMenu={handleTagMenu}
- layoutType={layoutType}
- showTags={showTags}
+ layoutType={layoutType.current}
+ showTags={showTags.current}
openFsEntry={openFsEntry}
handleGridContextMenu={handleGridContextMenu}
handleGridCellDblClick={handleGridCellDblClick}
@@ -724,11 +810,11 @@ function GridPerspective(props: Props) {
? PlatformIO.getLocationPath(props.currentLocation)
: '';
let entryWidth = 200;
- if (entrySize === 'small') {
+ if (entrySize.current === 'small') {
entryWidth = 150;
- } else if (entrySize === 'normal') {
+ } else if (entrySize.current === 'normal') {
entryWidth = 200;
- } else if (entrySize === 'big') {
+ } else if (entrySize.current === 'big') {
entryWidth = 300;
}
@@ -741,7 +827,7 @@ function GridPerspective(props: Props) {
>
<MainToolbar
classes={classes}
- layoutType={layoutType}
+ layoutType={layoutType.current}
isReadOnlyMode={props.isReadOnlyMode}
selectedEntries={selectedEntries}
loadParentDirectoryContent={loadParentDirectoryContent}
@@ -764,14 +850,16 @@ function GridPerspective(props: Props) {
allowChanges={true}
>
<GridPagination
- gridPageLimit={gridPageLimit}
+ gridPageLimit={gridPageLimit.current}
className={
- layoutType === 'grid' ? classes.gridContainer : classes.rowContainer
+ layoutType.current === 'grid'
+ ? classes.gridContainer
+ : classes.rowContainer
}
style={{
marginTop: 53,
gridTemplateColumns:
- layoutType === 'grid'
+ layoutType.current === 'grid'
? 'repeat(auto-fit,minmax(' + entryWidth + 'px,1fr))'
: 'none'
// gridTemplateRows:
@@ -780,7 +868,7 @@ function GridPerspective(props: Props) {
theme={theme}
// gridRef={this.mainGrid}
directories={sortedDirectories}
- showDirectories={showDirectories}
+ showDirectories={showDirectories.current}
files={sortedFiles}
renderCell={renderCell}
currentPage={1}
@@ -813,20 +901,26 @@ function GridPerspective(props: Props) {
{isGridSettingsDialogOpened && (
<GridSettingsDialog
open={isGridSettingsDialogOpened}
- onClose={() => setIsGridSettingsDialogOpened(false)}
+ onClose={isDefault => {
+ setIsGridSettingsDialogOpened(false);
+ isDefaultSetting.current = isDefault;
+ }}
setGridPageLimit={handleGridPageLimit}
- gridPageLimit={gridPageLimit}
+ gridPageLimit={gridPageLimit.current}
toggleShowDirectories={toggleShowDirectories}
toggleShowTags={toggleShowTags}
- showDirectories={showDirectories}
- showTags={showTags}
+ showDirectories={showDirectories.current}
+ showTags={showTags.current}
toggleThumbnailsMode={toggleThumbnailsMode}
- thumbnailMode={thumbnailMode}
+ thumbnailMode={thumbnailMode.current}
changeEntrySize={changeEntrySize}
- entrySize={entrySize}
+ entrySize={entrySize.current}
changeSingleClickAction={changeSingleClickAction}
- singleClickAction={singleClickAction}
+ singleClickAction={singleClickAction.current}
openHelpWebPage={openHelpWebPage}
+ sortBy={sortBy.current}
+ orderBy={orderBy.current}
+ handleSortingMenu={handleSortingMenu}
/>
)}
{isMoveCopyFilesDialogOpened && (
@@ -892,8 +986,8 @@ function GridPerspective(props: Props) {
open={Boolean(sortingContextMenuAnchorEl)}
onClose={() => setSortingContextMenuAnchorEl(null)}
anchorEl={sortingContextMenuAnchorEl}
- sortBy={sortBy}
- orderBy={orderBy}
+ sortBy={sortBy.current}
+ orderBy={orderBy.current}
handleSortBy={handleSortBy}
/>
)}
@@ -903,14 +997,14 @@ function GridPerspective(props: Props) {
onClose={closeOptionsMenu}
anchorEl={optionsContextMenuAnchorEl}
toggleShowDirectories={toggleShowDirectories}
- showDirectories={showDirectories}
+ showDirectories={showDirectories.current}
toggleShowTags={toggleShowTags}
- showTags={showTags}
+ showTags={showTags.current}
toggleThumbnailsMode={toggleThumbnailsMode}
- thumbnailMode={thumbnailMode}
- entrySize={entrySize}
+ thumbnailMode={thumbnailMode.current}
+ entrySize={entrySize.current}
changeSingleClickAction={changeSingleClickAction}
- singleClickAction={singleClickAction}
+ singleClickAction={singleClickAction.current}
changeEntrySize={changeEntrySize}
openHelpWebPage={openHelpWebPage}
openSettings={openSettings}
@@ -930,6 +1024,7 @@ function mapActionCreatorsToProps(dispatch) {
openURLExternally: AppActions.openURLExternally,
openNextFile: AppActions.openNextFile,
openPrevFile: AppActions.openPrevFile,
+ setDirectoryMeta: AppActions.setDirectoryMeta,
toggleDeleteMultipleEntriesDialog:
AppActions.toggleDeleteMultipleEntriesDialog,
addTags: TaggingActions.addTags,
@@ -941,6 +1036,7 @@ function mapActionCreatorsToProps(dispatch) {
function mapStateToProps(state) {
return {
+ directoryMeta: getDirectoryMeta(state),
supportedFileTypes: getSupportedFileTypes(state),
isReadOnlyMode: isReadOnlyMode(state),
lastSelectedEntry: getLastSelectedEntry(state),
diff --git a/app/perspectives/grid-perspective/index.tsx b/app/perspectives/grid-perspective/index.tsx
index 29833c6f4..def4c0dab 100644
--- a/app/perspectives/grid-perspective/index.tsx
+++ b/app/perspectives/grid-perspective/index.tsx
@@ -24,5 +24,6 @@ export const defaultSettings = {
entrySize: 'small', // small, normal, big
thumbnailMode: 'contain', // cover contain
showDirectories: true,
- showTags: true
+ showTags: true,
+ gridPageLimit: 100
};
diff --git a/app/perspectives/list/components/MainContainer.tsx b/app/perspectives/list/components/MainContainer.tsx
index eba7c83f6..cfbc1b5b0 100644
--- a/app/perspectives/list/components/MainContainer.tsx
+++ b/app/perspectives/list/components/MainContainer.tsx
@@ -16,7 +16,7 @@
*
*/
-import React, { useEffect, useMemo, useRef, useState } from 'react';
+import React, { useEffect, useMemo, useReducer, useRef, useState } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { GlobalHotKeys } from 'react-hotkeys';
@@ -26,6 +26,7 @@ import {
locationType,
sortByCriteria
} from '@tagspaces/tagspaces-platforms/misc';
+import AppConfig from '@tagspaces/tagspaces-platforms/AppConfig';
import { isVisibleOnScreen } from '-/utils/dom';
import { actions as TagLibraryActions } from '-/reducers/taglibrary';
import {
@@ -43,12 +44,12 @@ import AddRemoveTagsDialog from '-/components/dialogs/AddRemoveTagsDialog';
import MoveCopyFilesDialog from '-/components/dialogs/MoveCopyFilesDialog';
import TargetMoveFileBox from '-/components/TargetMoveFileBox';
import FileSourceDnd from '-/components/FileSourceDnd';
-import AppConfig from '@tagspaces/tagspaces-platforms/AppConfig';
import DragItemTypes from '-/components/DragItemTypes';
import TagDropContainer from '-/components/TagDropContainer';
import IOActions from '-/reducers/io-actions';
import {
actions as AppActions,
+ getDirectoryMeta,
getLastSelectedEntry,
getSelectedEntries,
isDeleteMultipleEntriesDialogOpened,
@@ -68,6 +69,7 @@ import { TS } from '-/tagspaces.namespace';
import { Pro } from '-/pro';
import Links from '-/links';
import { defaultSettings } from '../index';
+import { PerspectiveIDs } from '-/perspectives';
interface Props {
classes: any;
@@ -92,7 +94,7 @@ interface Props {
openFileNatively: (path?: string) => void;
openURLExternally: (path: string) => void;
loadParentDirectoryContent: () => void;
- setSelectedEntries: (selectedEntries: Array<Object>) => void;
+ setSelectedEntries: (selectedEntries: Array<TS.FileSystemEntry>) => void;
addTags: () => void;
addTag: (tag: TS.Tag, parentTagGroupUuid: TS.Uuid) => void;
removeTags: (paths: Array<string>, tags: Array<TS.Tag>) => void;
@@ -109,10 +111,25 @@ interface Props {
locations: Array<TS.Location>;
// isDesktopMode: boolean;
toggleDeleteMultipleEntriesDialog: () => void;
+ directoryMeta: TS.FileSystemEntryMeta;
+ setDirectoryMeta: (fsEntryMeta: TS.FileSystemEntryMeta) => void;
+}
+
+function getSettings(directoryMeta: TS.FileSystemEntryMeta) {
+ if (
+ directoryMeta &&
+ directoryMeta.perspectiveSettings &&
+ directoryMeta.perspectiveSettings[PerspectiveIDs.LIST]
+ ) {
+ return directoryMeta.perspectiveSettings[PerspectiveIDs.LIST];
+ } else {
+ // loading settings for not Pro
+ return JSON.parse(localStorage.getItem(defaultSettings.settingsKey));
+ }
}
function GridPerspective(props: Props) {
- let settings = JSON.parse(localStorage.getItem(defaultSettings.settingsKey)); // loading settings
+ const settings = getSettings(props.directoryMeta);
const [mouseX, setMouseX] = useState<number>(undefined);
const [mouseY, setMouseY] = useState<number>(undefined);
@@ -142,41 +159,40 @@ function GridPerspective(props: Props) {
const [isAddTagDialogOpened, setIsAddTagDialogOpened] = useState<TS.Tag>(
undefined
);
- const [sortBy, setSortBy] = useState<string>(
+ const sortBy = useRef<string>(
settings && settings.sortBy ? settings.sortBy : defaultSettings.sortBy
);
- const [orderBy, setOrderBy] = useState<null | boolean>(
+ const orderBy = useRef<null | boolean>(
settings && typeof settings.orderBy !== 'undefined'
? settings.orderBy
: defaultSettings.orderBy
);
- // const [layoutType, setLayoutType] = useState<string>(
- // settings && settings.layoutType
- // ? settings.layoutType
- // : defaultSettings.layoutType
- // );
- const [layoutType, setLayoutType] = useState<string>('row');
- const [singleClickAction, setSingleClickAction] = useState<string>(
+ const layoutType = useRef<string>(
+ settings && settings.layoutType
+ ? settings.layoutType
+ : defaultSettings.layoutType
+ );
+ const singleClickAction = useRef<string>(
settings && settings.singleClickAction
? settings.singleClickAction
: defaultSettings.singleClickAction
);
- const [entrySize, setEntrySize] = useState<string>(
+ const entrySize = useRef<string>(
settings && settings.entrySize
? settings.entrySize
: defaultSettings.entrySize
);
- const [thumbnailMode, setThumbnailMode] = useState<string>(
+ const thumbnailMode = useRef<string>(
settings && settings.thumbnailMode
? settings.thumbnailMode
: defaultSettings.thumbnailMode
);
- const [showDirectories, setShowDirectories] = useState<boolean>(
+ const showDirectories = useRef<boolean>(
settings && typeof settings.showDirectories !== 'undefined'
? settings.showDirectories
: defaultSettings.showDirectories
);
- const [showTags, setShowTags] = useState<boolean>(
+ const showTags = useRef<boolean>(
settings && typeof settings.showTags !== 'undefined'
? settings.showTags
: defaultSettings.showTags
@@ -192,38 +208,98 @@ function GridPerspective(props: Props) {
const [isGridSettingsDialogOpened, setIsGridSettingsDialogOpened] = useState<
boolean
>(false);
- const [gridPageLimit, setGridPageLimit] = useState<number>(
- settings && settings.gridPageLimit ? settings.gridPageLimit : 100
+ const gridPageLimit = useRef<number>(
+ settings && settings.gridPageLimit
+ ? settings.gridPageLimit
+ : defaultSettings.gridPageLimit
);
+ // true: save in default settings; false: save per folder settings; undefined - dont save changes
+ const isDefaultSetting = useRef<boolean>(undefined);
+ const [ignored, forceUpdate] = useReducer(x => x + 1, 0);
useEffect(() => {
makeFirstSelectedEntryVisible();
}, [props.selectedEntries]);
- settings = {
- showDirectories,
- showTags,
- layoutType,
- orderBy,
- sortBy,
- singleClickAction,
- entrySize,
- thumbnailMode,
- gridPageLimit
- };
+ useEffect(() => {
+ const perspectiveSettings = getSettings(props.directoryMeta);
+ showDirectories.current =
+ perspectiveSettings && perspectiveSettings.showDirectories !== undefined
+ ? perspectiveSettings.showDirectories
+ : defaultSettings.showDirectories;
+ showTags.current =
+ perspectiveSettings && perspectiveSettings.showTags !== undefined
+ ? perspectiveSettings.showTags
+ : defaultSettings.showTags;
+ layoutType.current = defaultSettings.layoutType;
+ orderBy.current =
+ perspectiveSettings && perspectiveSettings.orderBy !== undefined
+ ? perspectiveSettings.orderBy
+ : defaultSettings.orderBy;
+ sortBy.current =
+ perspectiveSettings && perspectiveSettings.sortBy !== undefined
+ ? perspectiveSettings.sortBy
+ : defaultSettings.sortBy;
+ singleClickAction.current =
+ perspectiveSettings && perspectiveSettings.singleClickAction !== undefined
+ ? perspectiveSettings.singleClickAction
+ : defaultSettings.singleClickAction;
+ entrySize.current =
+ perspectiveSettings && perspectiveSettings.entrySize !== undefined
+ ? perspectiveSettings.entrySize
+ : defaultSettings.entrySize;
+ thumbnailMode.current =
+ perspectiveSettings && perspectiveSettings.thumbnailMode !== undefined
+ ? perspectiveSettings.thumbnailMode
+ : defaultSettings.thumbnailMode;
+ gridPageLimit.current =
+ perspectiveSettings && perspectiveSettings.gridPageLimit !== undefined
+ ? perspectiveSettings.gridPageLimit
+ : defaultSettings.gridPageLimit;
+ forceUpdate();
+ }, [props.directoryMeta]);
useEffect(() => {
- localStorage.setItem(defaultSettings.settingsKey, JSON.stringify(settings));
+ if (isDefaultSetting.current !== undefined) {
+ const perspectiveSettings = {
+ showDirectories: showDirectories.current,
+ showTags: showTags.current,
+ layoutType: layoutType.current,
+ orderBy: orderBy.current,
+ sortBy: sortBy.current,
+ singleClickAction: singleClickAction.current,
+ entrySize: entrySize.current,
+ thumbnailMode: thumbnailMode.current,
+ gridPageLimit: gridPageLimit.current
+ };
+ if (Pro && !isDefaultSetting.current) {
+ Pro.MetaOperations.savePerspectiveSettings(
+ currentDirectoryPath,
+ PerspectiveIDs.LIST,
+ perspectiveSettings
+ ).then((fsEntryMeta: TS.FileSystemEntryMeta) => {
+ props.setDirectoryMeta(fsEntryMeta);
+ });
+ } else {
+ localStorage.setItem(
+ defaultSettings.settingsKey,
+ JSON.stringify(perspectiveSettings)
+ );
+ forceUpdate();
+ }
+ isDefaultSetting.current = undefined;
+ }
}, [
- showDirectories,
- showTags,
- layoutType,
- orderBy,
- sortBy,
- singleClickAction,
- entrySize,
- thumbnailMode,
- gridPageLimit
+ isDefaultSetting.current,
+ showDirectories.current,
+ showTags.current,
+ layoutType.current,
+ orderBy.current,
+ sortBy.current,
+ singleClickAction.current,
+ entrySize.current,
+ thumbnailMode.current,
+ gridPageLimit.current
]);
const fileOperationsEnabled = () => {
@@ -246,8 +322,9 @@ function GridPerspective(props: Props) {
};
const sortedDirContentMemoized = useMemo(
- () => sortByCriteria(props.directoryContent, sortBy, orderBy),
- [props.directoryContent, sortBy, orderBy]
+ () =>
+ sortByCriteria(props.directoryContent, sortBy.current, orderBy.current),
+ [props.directoryContent, sortBy.current, orderBy.current]
);
const makeFirstSelectedEntryVisible = () => {
@@ -266,24 +343,27 @@ function GridPerspective(props: Props) {
};
const handleLayoutSwitch = (type: string) => {
- setLayoutType(type);
+ layoutType.current = type;
+ // forceUpdate();
};
const handleGridPageLimit = (limit: number) => {
- setGridPageLimit(limit);
- setIsGridSettingsDialogOpened(false);
+ gridPageLimit.current = limit;
+ // setIsGridSettingsDialogOpened(false);
+ // forceUpdate();
};
const handleSortBy = handleSort => {
- if (sortBy !== handleSort) {
- setSortBy(handleSort);
+ if (sortBy.current !== handleSort) {
+ sortBy.current = handleSort;
} else {
- setOrderBy(!orderBy);
+ orderBy.current = !orderBy.current;
}
+ // forceUpdate();
setSortingContextMenuAnchorEl(null);
};
- const handleSortingMenu = event => {
+ const handleSortingMenu = (event) => {
const anchor = event ? event.currentTarget : null;
setSortingContextMenuAnchorEl(anchor);
};
@@ -346,9 +426,9 @@ function GridPerspective(props: Props) {
} else {
setSelectedEntries([fsEntry]);
if (fsEntry.isFile) {
- if (singleClickAction === 'openInternal') {
+ if (singleClickAction.current === 'openInternal') {
props.openFsEntry(fsEntry);
- } else if (singleClickAction === 'openExternal') {
+ } else if (singleClickAction.current === 'openExternal') {
props.openFileNatively(fsEntry.path);
}
}
@@ -380,28 +460,34 @@ function GridPerspective(props: Props) {
const toggleShowDirectories = () => {
closeOptionsMenu();
- setShowDirectories(!showDirectories);
+ showDirectories.current = !showDirectories.current;
+ // forceUpdate();
};
const toggleShowTags = () => {
closeOptionsMenu();
- setShowTags(!showTags);
+ showTags.current = !showTags.current;
+ // forceUpdate();
};
const toggleThumbnailsMode = () => {
closeOptionsMenu();
- const thumbMode = thumbnailMode === 'cover' ? 'contain' : 'cover';
- setThumbnailMode(thumbMode);
+ const thumbMode = thumbnailMode.current === 'cover' ? 'contain' : 'cover';
+ thumbnailMode.current = thumbMode;
+ // forceUpdate();
+ return thumbMode;
};
const changeEntrySize = size => {
closeOptionsMenu();
- setEntrySize(size);
+ entrySize.current = size;
+ // forceUpdate();
};
const changeSingleClickAction = singleClick => {
closeOptionsMenu();
- setSingleClickAction(singleClick);
+ singleClickAction.current = singleClick;
+ // forceUpdate();
};
const openHelpWebPage = () => {
@@ -550,22 +636,22 @@ function GridPerspective(props: Props) {
return;
}
if (monitor) {
- const mItems = monitor.getItem();
+ const mItem = monitor.getItem();
let arrPath;
- if (mItems.selectedEntries && mItems.selectedEntries.length > 0) {
- const arrSelected = mItems.selectedEntries
+ if (mItem.selectedEntries && mItem.selectedEntries.length > 0) {
+ const arrSelected = mItem.selectedEntries
.map(entry => entry.path)
// remove target folder selection
- .filter(epath => epath !== item.path);
+ .filter(epath => epath !== mItem.path);
if (arrSelected.length > 0) {
arrPath = arrSelected;
} else {
- arrPath = [mItems.path];
+ arrPath = [mItem.path];
}
} else {
- arrPath = [mItems.path];
+ arrPath = [mItem.path];
}
- console.log('Dropped files: ' + mItems.path);
+ console.log('Dropped files: ' + item.path);
props.moveFiles(arrPath, item.path);
clearSelection();
}
@@ -581,7 +667,7 @@ function GridPerspective(props: Props) {
supportedFileTypes,
openFsEntry
} = props;
- if (!fsEntry.isFile && !showDirectories) {
+ if (!fsEntry.isFile && !showDirectories.current) {
return;
}
@@ -603,12 +689,12 @@ function GridPerspective(props: Props) {
<CellContent
selected={selected}
fsEntry={fsEntry}
- entrySize={entrySize}
+ entrySize={entrySize.current}
classes={classes}
isLast={isLast}
theme={theme}
supportedFileTypes={supportedFileTypes}
- thumbnailMode={thumbnailMode}
+ thumbnailMode={thumbnailMode.current}
addTags={addTags}
addTag={addTag}
selectedEntries={selectedEntries}
@@ -616,8 +702,8 @@ function GridPerspective(props: Props) {
deselectEntry={deselectEntry}
isReadOnlyMode={props.isReadOnlyMode}
handleTagMenu={handleTagMenu}
- layoutType={layoutType}
- showTags={showTags}
+ layoutType={layoutType.current}
+ showTags={showTags.current}
openFsEntry={openFsEntry}
handleGridContextMenu={handleGridContextMenu}
handleGridCellDblClick={handleGridCellDblClick}
@@ -724,11 +810,11 @@ function GridPerspective(props: Props) {
? PlatformIO.getLocationPath(props.currentLocation)
: '';
let entryWidth = 200;
- if (entrySize === 'small') {
+ if (entrySize.current === 'small') {
entryWidth = 150;
- } else if (entrySize === 'normal') {
+ } else if (entrySize.current === 'normal') {
entryWidth = 200;
- } else if (entrySize === 'big') {
+ } else if (entrySize.current === 'big') {
entryWidth = 300;
}
@@ -741,7 +827,7 @@ function GridPerspective(props: Props) {
>
<MainToolbar
classes={classes}
- layoutType={layoutType}
+ layoutType={layoutType.current}
isReadOnlyMode={props.isReadOnlyMode}
selectedEntries={selectedEntries}
loadParentDirectoryContent={loadParentDirectoryContent}
@@ -764,14 +850,16 @@ function GridPerspective(props: Props) {
allowChanges={true}
>
<GridPagination
- gridPageLimit={gridPageLimit}
+ gridPageLimit={gridPageLimit.current}
className={
- layoutType === 'grid' ? classes.gridContainer : classes.rowContainer
+ layoutType.current === 'grid'
+ ? classes.gridContainer
+ : classes.rowContainer
}
style={{
marginTop: 53,
gridTemplateColumns:
- layoutType === 'grid'
+ layoutType.current === 'grid'
? 'repeat(auto-fit,minmax(' + entryWidth + 'px,1fr))'
: 'none'
// gridTemplateRows:
@@ -780,7 +868,7 @@ function GridPerspective(props: Props) {
theme={theme}
// gridRef={this.mainGrid}
directories={sortedDirectories}
- showDirectories={showDirectories}
+ showDirectories={showDirectories.current}
files={sortedFiles}
renderCell={renderCell}
currentPage={1}
@@ -813,20 +901,26 @@ function GridPerspective(props: Props) {
{isGridSettingsDialogOpened && (
<GridSettingsDialog
open={isGridSettingsDialogOpened}
- onClose={() => setIsGridSettingsDialogOpened(false)}
+ onClose={isDefault => {
+ setIsGridSettingsDialogOpened(false);
+ isDefaultSetting.current = isDefault;
+ }}
setGridPageLimit={handleGridPageLimit}
- gridPageLimit={gridPageLimit}
+ gridPageLimit={gridPageLimit.current}
toggleShowDirectories={toggleShowDirectories}
toggleShowTags={toggleShowTags}
- showDirectories={showDirectories}
- showTags={showTags}
+ showDirectories={showDirectories.current}
+ showTags={showTags.current}
toggleThumbnailsMode={toggleThumbnailsMode}
- thumbnailMode={thumbnailMode}
+ thumbnailMode={thumbnailMode.current}
changeEntrySize={changeEntrySize}
- entrySize={entrySize}
+ entrySize={entrySize.current}
changeSingleClickAction={changeSingleClickAction}
- singleClickAction={singleClickAction}
+ singleClickAction={singleClickAction.current}
openHelpWebPage={openHelpWebPage}
+ sortBy={sortBy.current}
+ orderBy={orderBy.current}
+ handleSortingMenu={handleSortingMenu}
/>
)}
{isMoveCopyFilesDialogOpened && (
@@ -892,8 +986,8 @@ function GridPerspective(props: Props) {
open={Boolean(sortingContextMenuAnchorEl)}
onClose={() => setSortingContextMenuAnchorEl(null)}
anchorEl={sortingContextMenuAnchorEl}
- sortBy={sortBy}
- orderBy={orderBy}
+ sortBy={sortBy.current}
+ orderBy={orderBy.current}
handleSortBy={handleSortBy}
/>
)}
@@ -903,14 +997,14 @@ function GridPerspective(props: Props) {
onClose={closeOptionsMenu}
anchorEl={optionsContextMenuAnchorEl}
toggleShowDirectories={toggleShowDirectories}
- showDirectories={showDirectories}
+ showDirectories={showDirectories.current}
toggleShowTags={toggleShowTags}
- showTags={showTags}
+ showTags={showTags.current}
toggleThumbnailsMode={toggleThumbnailsMode}
- thumbnailMode={thumbnailMode}
- entrySize={entrySize}
+ thumbnailMode={thumbnailMode.current}
+ entrySize={entrySize.current}
changeSingleClickAction={changeSingleClickAction}
- singleClickAction={singleClickAction}
+ singleClickAction={singleClickAction.current}
changeEntrySize={changeEntrySize}
openHelpWebPage={openHelpWebPage}
openSettings={openSettings}
@@ -930,6 +1024,7 @@ function mapActionCreatorsToProps(dispatch) {
openURLExternally: AppActions.openURLExternally,
openNextFile: AppActions.openNextFile,
openPrevFile: AppActions.openPrevFile,
+ setDirectoryMeta: AppActions.setDirectoryMeta,
toggleDeleteMultipleEntriesDialog:
AppActions.toggleDeleteMultipleEntriesDialog,
addTags: TaggingActions.addTags,
@@ -941,6 +1036,7 @@ function mapActionCreatorsToProps(dispatch) {
function mapStateToProps(state) {
return {
+ directoryMeta: getDirectoryMeta(state),
supportedFileTypes: getSupportedFileTypes(state),
isReadOnlyMode: isReadOnlyMode(state),
lastSelectedEntry: getLastSelectedEntry(state),
diff --git a/app/perspectives/list/index.tsx b/app/perspectives/list/index.tsx
index 0b059257c..da8e80b75 100644
--- a/app/perspectives/list/index.tsx
+++ b/app/perspectives/list/index.tsx
@@ -24,5 +24,6 @@ export const defaultSettings = {
entrySize: 'small', // small, normal, big
thumbnailMode: 'contain', // cover contain
showDirectories: true,
- showTags: true
+ showTags: true,
+ gridPageLimit: 100
};
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index bcc605ed5..782ae5f64 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -73,6 +73,7 @@ export const types = {
LOGIN_FAILURE: 'APP/LOGIN_FAILURE',
LOGOUT: 'APP/LOGOUT',
LOAD_DIRECTORY_SUCCESS: 'APP/LOAD_DIRECTORY_SUCCESS',
+ SET_DIRECTORY_META: 'APP/SET_DIRECTORY_META',
LOAD_DIRECTORY_FAILURE: 'APP/LOAD_DIRECTORY_FAILURE',
CLEAR_DIRECTORY_CONTENT: 'APP/CLEAR_DIRECTORY_CONTENT',
// LOAD_PAGE_CONTENT: 'APP/LOAD_PAGE_CONTENT',
@@ -269,6 +270,12 @@ export default (state: any = initialState, action: any) => {
isUpdateAvailable: action.isUpdateAvailable
};
}
+ case types.SET_DIRECTORY_META: {
+ return {
+ ...state,
+ directoryMeta: action.directoryMeta
+ };
+ }
case types.LOAD_DIRECTORY_SUCCESS: {
let { directoryPath } = action;
if (directoryPath && directoryPath.startsWith('./')) {
@@ -278,7 +285,7 @@ export default (state: any = initialState, action: any) => {
return {
...state,
currentDirectoryEntries: action.directoryContent,
- // pageEntries: [],
+ directoryMeta: action.directoryMeta,
currentDirectoryColor: action.directoryMeta
? action.directoryMeta.color || ''
: '',
@@ -997,7 +1004,7 @@ export const actions = {
);
// console.log('parentDirectory: ' + parentDirectory + ' - currentLocationPath: ' + currentLocationPath);
if (parentDirectory.includes(currentLocationPath)) {
- dispatch(actions.loadDirectoryContent(parentDirectory, false));
+ dispatch(actions.loadDirectoryContent(parentDirectory, false, true));
} else {
dispatch(
actions.showNotification(
@@ -1185,6 +1192,10 @@ export const actions = {
directoryMeta,
showIsLoading
}),
+ setDirectoryMeta: (directoryMeta: TS.FileSystemEntryMeta) => ({
+ type: types.SET_DIRECTORY_META,
+ directoryMeta
+ }),
loadDirectoryFailure: (directoryPath: string, error?: any) => (
dispatch: (action) => void
) => {
@@ -1610,7 +1621,11 @@ export const actions = {
dispatch(actions.setReadOnlyMode(location.isReadOnly || false));
dispatch(actions.changeLocation(location));
dispatch(
- actions.loadDirectoryContent(PlatformIO.getLocationPath(location), true)
+ actions.loadDirectoryContent(
+ PlatformIO.getLocationPath(location),
+ true,
+ true
+ )
);
if (Pro && Pro.Watcher && location.watchForChanges) {
const perspective = getCurrentDirectoryPerspective(getState());
@@ -2356,6 +2371,7 @@ export const getLastSelectedEntry = (state: any) => {
export const getSelectedTag = (state: any) => state.app.tag;
export const getSelectedEntries = (state: any) =>
state.app.selectedEntries ? state.app.selectedEntries : [];
+export const getDirectoryMeta = (state: any) => state.app.directoryMeta;
export const isGeneratingThumbs = (state: any) => state.app.isGeneratingThumbs;
export const isReadOnlyMode = (state: any) => state.app.isReadOnlyMode;
export const isOnboardingDialogOpened = (state: any) =>
diff --git a/app/services/utils-io.ts b/app/services/utils-io.ts
index 6d95d63a8..bbd80fd48 100644
--- a/app/services/utils-io.ts
+++ b/app/services/utils-io.ts
@@ -60,6 +60,7 @@ import {
supportedVideos,
supportedMisc
} from '-/services/thumbsgenerator';
+import { defaultSettings } from '-/perspectives/grid-perspective';
const supportedImgsWS = [
'jpg',
@@ -859,6 +860,64 @@ export function cleanMetaData(
if (metaData.dirs && metaData.dirs.length > 0) {
cleanedMeta.dirs = metaData.dirs;
}
+ if (metaData.perspectiveSettings) {
+ cleanedMeta.perspectiveSettings = metaData.perspectiveSettings;
+ }
+ /*if (metaData.perspectiveSettings) { // clean perspectiveSettings !== defaultSettings
+ Object.keys(metaData.perspectiveSettings).forEach(perspective => {
+ if (!cleanedMeta.perspectiveSettings) {
+ cleanedMeta.perspectiveSettings = {};
+ }
+ cleanedMeta.perspectiveSettings[perspective] = {
+ ...(metaData.perspectiveSettings[perspective].showDirectories !=
+ defaultSettings.showDirectories && {
+ showDirectories:
+ metaData.perspectiveSettings[perspective].showDirectories
+ }),
+ ...(metaData.perspectiveSettings[perspective].showTags !=
+ defaultSettings.showTags && {
+ showTags: metaData.perspectiveSettings[perspective].showTags
+ }),
+ ...(metaData.perspectiveSettings[perspective].layoutType !=
+ defaultSettings.layoutType && {
+ layoutType: metaData.perspectiveSettings[perspective].layoutType
+ }),
+ ...(metaData.perspectiveSettings[perspective].orderBy !=
+ defaultSettings.orderBy && {
+ orderBy: metaData.perspectiveSettings[perspective].orderBy
+ }),
+ ...(metaData.perspectiveSettings[perspective].sortBy !=
+ defaultSettings.sortBy && {
+ sortBy: metaData.perspectiveSettings[perspective].sortBy
+ }),
+ ...(metaData.perspectiveSettings[perspective].singleClickAction !=
+ defaultSettings.singleClickAction && {
+ singleClickAction:
+ metaData.perspectiveSettings[perspective].singleClickAction
+ }),
+ ...(metaData.perspectiveSettings[perspective].entrySize !=
+ defaultSettings.entrySize && {
+ entrySize: metaData.perspectiveSettings[perspective].entrySize
+ }),
+ ...(metaData.perspectiveSettings[perspective].thumbnailMode !=
+ defaultSettings.thumbnailMode && {
+ thumbnailMode: metaData.perspectiveSettings[perspective].thumbnailMode
+ }),
+ ...(metaData.perspectiveSettings[perspective].gridPageLimit !=
+ defaultSettings.gridPageLimit && {
+ gridPageLimit: metaData.perspectiveSettings[perspective].gridPageLimit
+ })
+ };
+ if (
+ Object.keys(cleanedMeta.perspectiveSettings[perspective]).length === 0
+ ) {
+ delete cleanedMeta.perspectiveSettings[perspective];
+ }
+ });
+ if (Object.keys(cleanedMeta.perspectiveSettings).length === 0) {
+ delete cleanedMeta.perspectiveSettings;
+ }
+ } */
if (metaData.tagGroups && metaData.tagGroups.length > 0) {
cleanedMeta.tagGroups = metaData.tagGroups;
}
diff --git a/app/tagspaces.namespace.d.ts b/app/tagspaces.namespace.d.ts
index 13d9d1dce..05c56c0fa 100644
--- a/app/tagspaces.namespace.d.ts
+++ b/app/tagspaces.namespace.d.ts
@@ -1,3 +1,5 @@
+import { PerspectiveIDs } from '-/perspectives';
+
/**
* TagSpaces - universal file and folder organizer
* Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
@@ -139,6 +141,28 @@ export namespace TS {
lastUpdated: string;
files?: Array<FileSystemEntry>;
dirs?: Array<FileSystemEntry>;
+ perspectiveSettings?: PerspectiveSettings;
+ }
+
+ interface PerspectiveSettings {
+ grid?: FolderSettings;
+ list?: FolderSettings;
+ gallery?: FolderSettings;
+ mapique?: FolderSettings;
+ kanban?: FolderSettings;
+ wiki?: FolderSettings;
+ }
+
+ interface FolderSettings {
+ showDirectories?: boolean;
+ showTags?: boolean;
+ layoutType?: string;
+ orderBy?: boolean;
+ sortBy?: string;
+ singleClickAction?: string;
+ entrySize?: string;
+ thumbnailMode?: string;
+ gridPageLimit?: number;
}
interface MapTileServer {
diff --git a/package-lock.json b/package-lock.json
index 0212fb4a7..441d53de3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -19,7 +19,7 @@
"@mui/lab": "^5.0.0-alpha.92",
"@mui/material": "^5.9.2",
"@mui/styles": "^5.9.2",
- "@tagspaces/tagspaces-platforms": "2.0.13",
+ "@tagspaces/tagspaces-platforms": "2.0.15",
"aws-amplify": "^4.3.8",
"aws-sdk": "^2.1036.0",
"babel-polyfill": "^6.26.0",
@@ -11720,9 +11720,9 @@
}
},
"node_modules/@tagspaces/tagspaces-platforms": {
- "version": "2.0.13",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-platforms/-/tagspaces-platforms-2.0.13.tgz",
- "integrity": "sha512-XpJSQipb1VI04spUzr+VtWATdeJ7zj24jU7zT1JogBoiHpvXX6g9dFtqDfDILjMf7KzGDi1J9Lrpg63AGL0h0g==",
+ "version": "2.0.15",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-platforms/-/tagspaces-platforms-2.0.15.tgz",
+ "integrity": "sha512-HIXul2UbesfHIJ7T8rWQHazsOxcwRHm/OfnMDWieOt0NOGyUIR1tVtuPVe80/oRO0E4X3HaXYq100ozNSCUwJg==",
"hasInstallScript": true
},
"node_modules/@testim/chrome-version": {
@@ -59559,9 +59559,9 @@
}
},
"@tagspaces/tagspaces-platforms": {
- "version": "2.0.13",
- "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-platforms/-/tagspaces-platforms-2.0.13.tgz",
- "integrity": "sha512-XpJSQipb1VI04spUzr+VtWATdeJ7zj24jU7zT1JogBoiHpvXX6g9dFtqDfDILjMf7KzGDi1J9Lrpg63AGL0h0g=="
+ "version": "2.0.15",
+ "resolved": "https://registry.npmjs.org/@tagspaces/tagspaces-platforms/-/tagspaces-platforms-2.0.15.tgz",
+ "integrity": "sha512-HIXul2UbesfHIJ7T8rWQHazsOxcwRHm/OfnMDWieOt0NOGyUIR1tVtuPVe80/oRO0E4X3HaXYq100ozNSCUwJg=="
},
"@testim/chrome-version": {
"version": "1.1.2",
diff --git a/package.json b/package.json
index 05707d10f..1ac9a4901 100644
--- a/package.json
+++ b/package.json
@@ -154,7 +154,7 @@
"@mui/lab": "^5.0.0-alpha.92",
"@mui/material": "^5.9.2",
"@mui/styles": "^5.9.2",
- "@tagspaces/tagspaces-platforms": "2.0.13",
+ "@tagspaces/tagspaces-platforms": "2.0.15",
"aws-amplify": "^4.3.8",
"aws-sdk": "^2.1036.0",
"babel-polyfill": "^6.26.0",
diff --git a/tests/e2e/general.helpers.js b/tests/e2e/general.helpers.js
index 8281588fa..8c4a82f09 100644
--- a/tests/e2e/general.helpers.js
+++ b/tests/e2e/general.helpers.js
@@ -448,7 +448,7 @@ export async function setGridOptions(
if (entrySize) {
await clickOn('[data-tid=' + entrySize + ']');
}
- await clickOn('[data-tid=cancelDialog]');
+ await clickOn('[data-tid=defaultSettings]');
}
/**
*