Skip to content

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

add SelectedEntryContextProvider.tsx (#1992)

Stanimir163e694514a9
diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml
index d72053f64..63b1b029f 100644
--- a/.github/workflows/pull_request.yml
+++ b/.github/workflows/pull_request.yml
@@ -78,7 +78,7 @@ jobs:
- name: Checkout TagspacesPro
uses: actions/checkout@v2
with:
- ref: refactoring-directoryContent
+ ref: add-selected-item-context-provider
repository: tagspaces/tagspacespro
token: ${{ secrets.CHECKOUT_TSPRO }}
path: extensions/tagspacespro
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index 59814dfa1..66a710824 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -68,6 +68,7 @@ import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
+import { toFsEntry } from '-/services/utils-io';
//const defaultSplitSize = '7.86%'; // '7.2%'; // 103;
// const bufferedSplitResize = buffer({
@@ -983,7 +984,9 @@ function EntryContainer() {
<AddRemoveTagsDialog
open={isEditTagsModalOpened}
onClose={() => setEditTagsModalOpened(false)}
- selectedEntries={openedFile ? [openedFile] : []}
+ selected={
+ openedFile ? [toFsEntry(openedFile.path, openedFile.isFile)] : []
+ }
/>
)}
<ResolveConflictDialog
diff --git a/app/components/EntryContainerMenu.tsx b/app/components/EntryContainerMenu.tsx
index 5b6e01eb7..54cd8c53c 100644
--- a/app/components/EntryContainerMenu.tsx
+++ b/app/components/EntryContainerMenu.tsx
@@ -13,12 +13,8 @@ import {
MenuList,
Divider
} from '@mui/material';
-import {
- actions as AppActions,
- AppDispatch,
- OpenedEntry
-} from '-/reducers/app';
-import { useDispatch, useSelector } from 'react-redux';
+import { OpenedEntry } from '-/reducers/app';
+import { useSelector } from 'react-redux';
import AppConfig from '-/AppConfig';
import {
DeleteIcon,
@@ -33,7 +29,10 @@ import OpenNativelyIcon from '@mui/icons-material/Launch';
import FullScreenIcon from '@mui/icons-material/ZoomOutMap';
import FileDownloadIcon from '@mui/icons-material/AssignmentReturned';
import ConfirmDialog from '-/components/dialogs/ConfirmDialog';
-import { isDesktopMode } from '-/reducers/settings';
+import {
+ getWarningOpeningFilesExternally,
+ isDesktopMode
+} from '-/reducers/settings';
import { useTranslation } from 'react-i18next';
import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
@@ -67,7 +66,9 @@ function EntryContainerMenu(props: Props) {
const { deleteFile } = useFsActionsContext();
const { showNotification } = useNotificationContext();
const desktopMode = useSelector(isDesktopMode);
- const dispatch: AppDispatch = useDispatch();
+ const warningOpeningFilesExternally = useSelector(
+ getWarningOpeningFilesExternally
+ );
const [isDeleteEntryModalOpened, setDeleteEntryModalOpened] = useState<
boolean
@@ -173,7 +174,8 @@ function EntryContainerMenu(props: Props) {
const openNatively = () => {
if (openedEntry.path) {
if (openedEntry.isFile) {
- dispatch(AppActions.openFileNatively(openedEntry.path));
+ PlatformIO.openFile(openedEntry.path, warningOpeningFilesExternally);
+ //dispatch(AppActions.openFileNatively(openedEntry.path));
} else {
PlatformIO.openDirectory(openedEntry.path);
}
diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsx
index 59be4ad22..7df55c905 100644
--- a/app/components/EntryProperties.tsx
+++ b/app/components/EntryProperties.tsx
@@ -201,7 +201,6 @@ interface Props {
folderPath: string,
lastBackgroundColorChange: number
) => void;
- setSelectedEntries: (selectedEntries: Array<TS.FileSystemEntry>) => void;
}
const defaultBackgrounds = [
@@ -1393,8 +1392,7 @@ function mapStateToProps(state) {
function mapActionCreatorsToProps(dispatch) {
return bindActionCreators(
{
- setLastBackgroundColorChange: AppActions.setLastBackgroundColorChange,
- setSelectedEntries: AppActions.setSelectedEntries
+ setLastBackgroundColorChange: AppActions.setLastBackgroundColorChange
},
dispatch
);
diff --git a/app/components/FileUploadContainer.tsx b/app/components/FileUploadContainer.tsx
index 415aa1156..a6fda88c1 100644
--- a/app/components/FileUploadContainer.tsx
+++ b/app/components/FileUploadContainer.tsx
@@ -21,6 +21,8 @@ import { useDispatch } from 'react-redux';
import { TS } from '-/tagspaces.namespace';
import { actions as AppActions, AppDispatch } from '-/reducers/app';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
+import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
interface Props {
id: string;
@@ -37,6 +39,11 @@ const FileUploadContainer = forwardRef(
const dispatch: AppDispatch = useDispatch();
const { id, directoryPath } = props;
const { uploadFilesAPI } = useIOActionsContext();
+ const { setSelectedEntries } = useSelectedEntriesContext();
+ const {
+ currentDirectoryPath,
+ addDirectoryEntries
+ } = useDirectoryContentContext();
const onUploadProgress = (progress, abort, fileName) => {
dispatch(AppActions.onUploadProgress(progress, abort, fileName));
@@ -93,7 +100,11 @@ const FileUploadContainer = forwardRef(
onUploadProgress
)
.then((fsEntries: Array<TS.FileSystemEntry>) => {
- dispatch(AppActions.reflectCreateEntries(fsEntries));
+ if (directoryPath === currentDirectoryPath) {
+ addDirectoryEntries(fsEntries);
+ dispatch(AppActions.reflectCreateEntries(fsEntries));
+ setSelectedEntries(fsEntries);
+ }
return true;
})
.catch(error => {
diff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsx
index bc0345efd..b6d002a0d 100644
--- a/app/components/FolderContainer.tsx
+++ b/app/components/FolderContainer.tsx
@@ -34,11 +34,7 @@ import {
getDesktopMode,
getDefaultPerspective
} from '-/reducers/settings';
-import {
- actions as AppActions,
- getSelectedEntries,
- getProgress
-} from '../reducers/app';
+import { actions as AppActions, getProgress } from '../reducers/app';
import {
GoBackIcon,
GoForwardIcon,
@@ -59,14 +55,12 @@ import RenderPerspective from '-/components/RenderPerspective';
import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';
interface Props {
- setSelectedEntries: (selectedEntries: Array<Object>) => void;
isDesktopMode: boolean;
toggleDrawer?: () => void;
toggleProTeaser: (slidePage?: string) => void;
drawerOpened: boolean;
maxSearchResults: number;
defaultPerspective: string;
- selectedEntries: Array<TS.FileSystemEntry>;
toggleUploadDialog: () => void;
progress?: Array<any>;
goBack: () => void;
@@ -78,7 +72,6 @@ function FolderContainer(props: Props) {
toggleDrawer,
toggleProTeaser,
isDesktopMode,
- setSelectedEntries,
defaultPerspective,
goBack,
goForward
@@ -337,7 +330,6 @@ function FolderContainer(props: Props) {
)}
<PathBreadcrumbs
switchPerspective={switchPerspective}
- setSelectedEntries={setSelectedEntries}
isDesktopMode={isDesktopMode}
openRenameDirectoryDialog={() => setRenameEntryDialogOpened(true)}
/>
@@ -385,7 +377,6 @@ function FolderContainer(props: Props) {
function mapStateToProps(state) {
return {
- selectedEntries: getSelectedEntries(state),
maxSearchResults: getMaxSearchResults(state),
isDesktopMode: getDesktopMode(state),
progress: getProgress(state),
@@ -396,8 +387,7 @@ function mapStateToProps(state) {
function mapActionCreatorsToProps(dispatch) {
return bindActionCreators(
{
- toggleUploadDialog: AppActions.toggleUploadDialog,
- setSelectedEntries: AppActions.setSelectedEntries
+ toggleUploadDialog: AppActions.toggleUploadDialog
},
dispatch
);
diff --git a/app/components/LocationView.tsx b/app/components/LocationView.tsx
index 16ad9acbd..7a1383b43 100644
--- a/app/components/LocationView.tsx
+++ b/app/components/LocationView.tsx
@@ -43,6 +43,8 @@ import { useTranslation } from 'react-i18next';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
+import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
interface Props {
location: TS.Location;
@@ -63,7 +65,12 @@ function LocationView(props: Props) {
locationDirectoryContextMenuAnchorEl,
setLocationDirectoryContextMenuAnchorEl
} = useCurrentLocationContext();
- const { reloadDirectory } = useIOActionsContext();
+ const { setSelectedEntries } = useSelectedEntriesContext();
+ const {
+ currentDirectoryPath,
+ addDirectoryEntries,
+ openDirectory
+ } = useDirectoryContentContext();
const { showNotification } = useNotificationContext();
const directoryTreeRef = useRef<DirectoryTreeViewRef>(null);
/* const [
@@ -94,10 +101,10 @@ function LocationView(props: Props) {
const handleLocationClick = () => {
if (currentLocation && location.uuid === currentLocation.uuid) {
// the same location click
- reloadDirectory(PlatformIO.getLocationPath(location));
+ openDirectory(PlatformIO.getLocationPath(location));
} else {
// this.directoryTreeRef[location.uuid].loadSubDir(location, 1);
- dispatch(AppActions.setSelectedEntries([]));
+ setSelectedEntries([]);
openLocation(location);
if (hideDrawer) {
hideDrawer();
@@ -166,7 +173,11 @@ function LocationView(props: Props) {
dispatch(AppActions.toggleUploadDialog());
uploadFiles(arrPath, targetPath, onUploadProgress)
.then((fsEntries: Array<TS.FileSystemEntry>) => {
- dispatch(AppActions.reflectCreateEntries(fsEntries));
+ if (targetPath === currentDirectoryPath) {
+ addDirectoryEntries(fsEntries);
+ dispatch(AppActions.reflectCreateEntries(fsEntries));
+ setSelectedEntries(fsEntries);
+ }
return true;
})
.catch(error => {
@@ -181,7 +192,7 @@ function LocationView(props: Props) {
PlatformIO.disableObjectStoreSupport();
moveFiles(arrPath, targetPath);
}
- dispatch(AppActions.setSelectedEntries([]));
+ setSelectedEntries([]);
}
}
};
diff --git a/app/components/PathBreadcrumbs.tsx b/app/components/PathBreadcrumbs.tsx
index a286db7b3..ae67355a3 100644
--- a/app/components/PathBreadcrumbs.tsx
+++ b/app/components/PathBreadcrumbs.tsx
@@ -34,6 +34,7 @@ import { locationType } from '@tagspaces/tagspaces-common/misc';
import { useTranslation } from 'react-i18next';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
const StyledBreadcrumb = styled(Chip)(({ theme }) => {
const backgroundColor =
@@ -72,16 +73,15 @@ const StyledBreadcrumbs = styled(Breadcrumbs)(({ theme }) => {
interface Props {
switchPerspective: (perspectiveId: string) => void;
- setSelectedEntries: (selectedEntries: Array<Object>) => void;
openRenameDirectoryDialog: () => void;
isDesktopMode: boolean;
}
function PathBreadcrumbs(props: Props) {
const { t } = useTranslation();
- //const dispatch: AppDispatch = useDispatch();
const { openDirectory, currentDirectoryPath } = useDirectoryContentContext();
const { currentLocation } = useCurrentLocationContext();
+ const { setSelectedEntries } = useSelectedEntriesContext();
let pathParts: Array<string> = [];
const [
@@ -89,11 +89,7 @@ function PathBreadcrumbs(props: Props) {
setDirectoryContextMenuAnchorEl
] = useState<null | HTMLElement>(null);
- const {
- setSelectedEntries,
- openRenameDirectoryDialog,
- isDesktopMode
- } = props;
+ const { openRenameDirectoryDialog, isDesktopMode } = props;
const openDirectoryMenu = (event: React.MouseEvent<Element, MouseEvent>) => {
event.preventDefault();
diff --git a/app/components/TagContainer.tsx b/app/components/TagContainer.tsx
index ccfde3c1f..22b1e7bd5 100644
--- a/app/components/TagContainer.tsx
+++ b/app/components/TagContainer.tsx
@@ -29,6 +29,7 @@ import { isDateTimeTag, convertToDateTime, convertToDate } from '-/utils/dates';
import { TS } from '-/tagspaces.namespace';
import { getTagColors } from '-/services/taglibrary-utils';
import TagContainerMenu from '-/components/TagContainerMenu';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
interface Props {
tag: TS.Tag;
@@ -50,7 +51,6 @@ interface Props {
fromTagGroupId: TS.Uuid,
toTagGroupId: TS.Uuid
) => void;
- selectedEntries?: Array<TS.FileSystemEntry>;
reorderTags?: boolean;
}
@@ -63,12 +63,12 @@ function TagContainer(props: Props) {
entryPath,
handleRemoveTag,
handleTagMenu,
- selectedEntries,
addTags,
tagMode
} = props;
let { title } = tag;
+ const { selectedEntries } = useSelectedEntriesContext();
const defaultBackgroundColor = useSelector(getTagColor);
const defaultTextColor = useSelector(getTagTextColor);
diff --git a/app/components/TagContainerDnd.tsx b/app/components/TagContainerDnd.tsx
index 56abf6311..e6f6070cb 100644
--- a/app/components/TagContainerDnd.tsx
+++ b/app/components/TagContainerDnd.tsx
@@ -226,19 +226,30 @@ const TagContainerDnd = (props: Props) => {
entryPath,
handleTagMenu,
deleteIcon,
- selectedEntries,
isDragging,
connectDragSource,
connectDropTarget,
addTags,
tagMode,
tagContainerRef,
- reorderTags
+ reorderTags,
+ connectDragPreview
} = props;
+ /* const [{ opacity }, dragRef] = useDrag(
+ () => ({
+ type: DragItemTypes.TAG,
+ item: { text },
+ collect: monitor => ({
+ opacity: monitor.isDragging() ? 0.5 : 1
+ })
+ }),
+ []
+ );*/
+
// Use empty image as a drag preview so browsers don't draw it
// and we can draw whatever we want on the custom drag layer instead.
- props.connectDragPreview(getEmptyImage(), {
+ connectDragPreview(getEmptyImage(), {
// IE fallback: specify that we'd rather screenshot the node
// when it already knows it's being dragged so we can hide it with CSS.
captureDraggingState: true
@@ -256,7 +267,6 @@ const TagContainerDnd = (props: Props) => {
tagMode={tagMode}
entryPath={entryPath}
isDragging={isDragging}
- selectedEntries={selectedEntries}
reorderTags={reorderTags}
/>
</span>
diff --git a/app/components/TagLibrary.tsx b/app/components/TagLibrary.tsx
index e7e5a2d6c..8e607505a 100644
--- a/app/components/TagLibrary.tsx
+++ b/app/components/TagLibrary.tsx
@@ -41,15 +41,11 @@ import {
getTagGroupCollapsed,
getTagTextColor
} from '../reducers/settings';
-import {
- AppDispatch,
- getSelectedEntries,
- isTagLibraryChanged
-} from '-/reducers/app';
+import { AppDispatch, isTagLibraryChanged } from '-/reducers/app';
import SmartTags from '../reducers/smart-tags';
import EditTagDialog from '-/components/dialogs/EditTagDialog';
import { TS } from '-/tagspaces.namespace';
-import { actions as LocationActions, getLocations } from '-/reducers/locations';
+import { getLocations } from '-/reducers/locations';
import { Pro } from '-/pro';
import TagGroupTitleDnD from '-/components/TagGroupTitleDnD';
import {
@@ -72,9 +68,9 @@ import {
import useFirstRender from '-/utils/useFirstRender';
import { classes, SidePanel } from '-/components/SidePanels.css';
import { useTranslation } from 'react-i18next';
-import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
interface Props {
style?: any;
@@ -84,6 +80,7 @@ interface Props {
function TagLibrary(props: Props) {
const { t } = useTranslation();
const { addTags } = useTaggingActionsContext();
+ const { selectedEntries } = useSelectedEntriesContext();
const {
switchLocationTypeByID,
switchCurrentLocationType,
@@ -92,9 +89,6 @@ function TagLibrary(props: Props) {
const dispatch: AppDispatch = useDispatch();
const tagBackgroundColor = useSelector(getTagColor);
const tagTextColor = useSelector(getTagTextColor);
- const selectedEntries: Array<TS.FileSystemEntry> = useSelector(
- getSelectedEntries
- );
const tagGroupCollapsed: Array<string> = useSelector(getTagGroupCollapsed);
const locations: Array<TS.Location> = useSelector(getLocations);
const saveTagInLocation: boolean = useSelector(getSaveTagInLocation);
@@ -314,7 +308,6 @@ function TagLibrary(props: Props) {
tagGroups
)
}*/
- selectedEntries={selectedEntries}
/>
);
}
diff --git a/app/components/TargetFileBox.tsx b/app/components/TargetFileBox.tsx
index 57802db9a..2d280d8bb 100644
--- a/app/components/TargetFileBox.tsx
+++ b/app/components/TargetFileBox.tsx
@@ -30,6 +30,7 @@ import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
type DragItem = { files: File[]; items: DataTransferItemList };
type DragProps = { isActive: boolean; handlerId: Identifier | null };
@@ -44,9 +45,13 @@ function TargetFileBox(props: Props) {
const { t } = useTranslation();
const dispatch: AppDispatch = useDispatch();
const { readOnlyMode } = useCurrentLocationContext();
- const { currentDirectoryPath } = useDirectoryContentContext();
const { uploadFilesAPI } = useIOActionsContext();
const { showNotification } = useNotificationContext();
+ const { setSelectedEntries } = useSelectedEntriesContext();
+ const {
+ currentDirectoryPath,
+ addDirectoryEntries
+ } = useDirectoryContentContext();
const ref = useRef<HTMLDivElement>(null);
const { setMoveCopyDialogOpened } = props;
@@ -77,7 +82,9 @@ function TargetFileBox(props: Props) {
dispatch(AppActions.toggleUploadDialog());
return uploadFilesAPI(files, currentDirectoryPath, onUploadProgress)
.then((fsEntries: Array<TS.FileSystemEntry>) => {
+ addDirectoryEntries(fsEntries);
dispatch(AppActions.reflectCreateEntries(fsEntries));
+ setSelectedEntries(fsEntries);
return true;
})
.catch(error => {
diff --git a/app/components/dialogs/AddRemoveTagsDialog.tsx b/app/components/dialogs/AddRemoveTagsDialog.tsx
index 3398fceb7..1d909a537 100644
--- a/app/components/dialogs/AddRemoveTagsDialog.tsx
+++ b/app/components/dialogs/AddRemoveTagsDialog.tsx
@@ -17,7 +17,6 @@
*/
import React, { useState } from 'react';
-import { useDispatch } from 'react-redux';
import Button from '@mui/material/Button';
import Paper from '@mui/material/Paper';
import DialogActions from '@mui/material/DialogActions';
@@ -41,19 +40,21 @@ import { TS } from '-/tagspaces.namespace';
import DialogCloseButton from '-/components/dialogs/DialogCloseButton';
import { useTheme } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';
-import { AppDispatch } from '-/reducers/app';
import { useTranslation } from 'react-i18next';
import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
interface Props {
open: boolean;
- selectedEntries: Array<any>;
onClose: (clearSelection?: boolean) => void;
+ selected?: TS.FileSystemEntry[];
}
function AddRemoveTagsDialog(props: Props) {
const { t } = useTranslation();
+ const { selectedEntries } = useSelectedEntriesContext();
+ const selected = props.selected ? props.selected : selectedEntries;
const { addTags, removeTags, removeAllTags } = useTaggingActionsContext();
const [newlyAddedTags, setNewlyAddedTags] = useState<Array<TS.Tag>>([]);
@@ -78,9 +79,9 @@ function AddRemoveTagsDialog(props: Props) {
};
const addTagsAction = () => {
- if (props.selectedEntries && props.selectedEntries.length > 0) {
+ if (selected && selected.length > 0) {
addTags(
- selectedEntries.map(entry => entry.path),
+ selected.map(entry => entry.path),
newlyAddedTags
);
}
@@ -88,10 +89,9 @@ function AddRemoveTagsDialog(props: Props) {
};
const removeTagsAction = () => {
- const { selectedEntries } = props;
- if (selectedEntries && selectedEntries.length > 0) {
+ if (selected && selected.length > 0) {
removeTags(
- selectedEntries.map(entry => entry.path),
+ selected.map(entry => entry.path),
newlyAddedTags
);
}
@@ -99,16 +99,15 @@ function AddRemoveTagsDialog(props: Props) {
};
const removeAllTagsAction = () => {
- const { selectedEntries } = props;
- if (selectedEntries && selectedEntries.length > 0) {
- removeAllTags(selectedEntries.map(entry => entry.path));
+ if (selected && selected.length > 0) {
+ removeAllTags(selected.map(entry => entry.path));
}
onCloseDialog(true);
};
- const { open, selectedEntries = [] } = props;
+ const { open } = props;
const disabledButtons =
- !newlyAddedTags || newlyAddedTags.length < 1 || selectedEntries.length < 1;
+ !newlyAddedTags || newlyAddedTags.length < 1 || selected.length < 1;
const theme = useTheme();
const fullScreen = useMediaQuery(theme.breakpoints.down('md'));
@@ -147,8 +146,8 @@ function AddRemoveTagsDialog(props: Props) {
{t('selectedFilesAndFolders')}
</Typography>
<List dense style={{ width: 550, marginLeft: -15 }}>
- {selectedEntries.length > 0 &&
- selectedEntries.map(entry => (
+ {selected.length > 0 &&
+ selected.map(entry => (
<ListItem key={entry.path} title={entry.path}>
<ListItemIcon>
{entry.isFile ? <FileIcon /> : <FolderIcon />}
@@ -179,7 +178,7 @@ function AddRemoveTagsDialog(props: Props) {
</Button>
<Button
data-tid="cleanTagsMultipleEntries"
- disabled={selectedEntries.length < 1}
+ disabled={selected.length < 1}
color="primary"
onClick={removeAllTagsAction}
>
diff --git a/app/components/dialogs/CreateEditLocationDialog.tsx b/app/components/dialogs/CreateEditLocationDialog.tsx
index 16b6aa014..d37391939 100644
--- a/app/components/dialogs/CreateEditLocationDialog.tsx
+++ b/app/components/dialogs/CreateEditLocationDialog.tsx
@@ -92,10 +92,8 @@ const StyledDialog = styled(Dialog)(({ theme }) => ({
}));
interface Props {
- /*location?: TS.Location;*/
open: boolean;
onClose: () => void;
- classes: any;
editLocation?: (location: TS.Location) => void;
}
diff --git a/app/components/dialogs/EditEntryTagDialog.tsx b/app/components/dialogs/EditEntryTagDialog.tsx
index 68e97eada..fdad74f4a 100644
--- a/app/components/dialogs/EditEntryTagDialog.tsx
+++ b/app/components/dialogs/EditEntryTagDialog.tsx
@@ -37,7 +37,7 @@ import Dialog from '@mui/material/Dialog';
import EditIcon from '@mui/icons-material/Edit';
import { isGeoTag } from '-/utils/geo';
import { Pro } from '-/pro';
-import { getSelectedEntries, getSelectedTag } from '-/reducers/app';
+import { getSelectedTag } from '-/reducers/app';
import { isDateTimeTag } from '-/utils/dates';
import { TS } from '-/tagspaces.namespace';
import useValidation from '-/utils/useValidation';
@@ -51,7 +51,6 @@ import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';
interface Props {
open: boolean;
onClose: () => void;
- selectedEntries: Array<TS.FileSystemEntry>;
selectedTag: TS.Tag;
tileServer: TS.MapTileServer;
geoTaggingFormat: string;
@@ -258,7 +257,6 @@ function EditEntryTagDialog(props: Props) {
function mapStateToProps(state) {
return {
selectedTag: getSelectedTag(state),
- selectedEntries: getSelectedEntries(state),
tileServer: getMapTileServer(state),
geoTaggingFormat: state.settings.geoTaggingFormat
};
diff --git a/app/components/dialogs/MoveCopyFilesDialog.tsx b/app/components/dialogs/MoveCopyFilesDialog.tsx
index 8fb463835..d8ab10b1b 100644
--- a/app/components/dialogs/MoveCopyFilesDialog.tsx
+++ b/app/components/dialogs/MoveCopyFilesDialog.tsx
@@ -17,11 +17,7 @@ import PlatformIO from '-/services/platform-facade';
import DialogCloseButton from '-/components/dialogs/DialogCloseButton';
import { useTheme } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';
-import {
- actions as AppActions,
- AppDispatch,
- getSelectedEntries
-} from '-/reducers/app';
+import { actions as AppActions, AppDispatch } from '-/reducers/app';
import { TS } from '-/tagspaces.namespace';
import DirectoryListView from '-/components/DirectoryListView';
import AppConfig from '-/AppConfig';
@@ -34,6 +30,7 @@ import {
import { useTranslation } from 'react-i18next';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
interface Props {
open: boolean;
@@ -47,10 +44,8 @@ function MoveCopyFilesDialog(props: Props) {
const dispatch: AppDispatch = useDispatch();
const { currentDirectoryPath } = useDirectoryContentContext();
const { copyFiles, copyDirs, moveFiles, moveDirs } = useIOActionsContext();
+ const { selectedEntries } = useSelectedEntriesContext();
- const selectedEntries: Array<TS.FileSystemEntry> = useSelector(
- getSelectedEntries
- );
const [targetPath, setTargetPath] = useState(
currentDirectoryPath ? currentDirectoryPath : ''
);
diff --git a/app/components/dialogs/RenameEntryDialog.tsx b/app/components/dialogs/RenameEntryDialog.tsx
index 213fc3a83..e9ae35eab 100644
--- a/app/components/dialogs/RenameEntryDialog.tsx
+++ b/app/components/dialogs/RenameEntryDialog.tsx
@@ -33,17 +33,13 @@ import {
} from '@tagspaces/tagspaces-common/paths';
import DraggablePaper from '-/components/DraggablePaper';
import AppConfig from '-/AppConfig';
-import {
- actions as AppActions,
- AppDispatch,
- getLastSelectedEntry
-} from '-/reducers/app';
import PlatformIO from '-/services/platform-facade';
import DialogCloseButton from '-/components/dialogs/DialogCloseButton';
import { dirNameValidation, fileNameValidation } from '-/services/utils-io';
import { useTranslation } from 'react-i18next';
import { useFsActionsContext } from '-/hooks/useFsActionsContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
interface Props {
open: boolean;
@@ -55,9 +51,10 @@ function RenameEntryDialog(props: Props) {
const { t } = useTranslation();
const { renameDirectory, renameFile } = useFsActionsContext();
const { currentDirectoryPath } = useDirectoryContentContext();
+ const { selectedEntries } = useSelectedEntriesContext();
+ const lastSelectedEntry = selectedEntries[selectedEntries.length - 1];
const [inputError, setInputError] = useState<boolean>(false);
const disableConfirmButton = useRef<boolean>(true);
- const lastSelectedEntry = useSelector(getLastSelectedEntry);
let defaultName = '';
let originPath;
diff --git a/app/components/dialogs/hooks/TargetPathContextProvider.tsx b/app/components/dialogs/hooks/TargetPathContextProvider.tsx
index 1e115176f..140b70b3e 100644
--- a/app/components/dialogs/hooks/TargetPathContextProvider.tsx
+++ b/app/components/dialogs/hooks/TargetPathContextProvider.tsx
@@ -18,10 +18,10 @@
import React, { createContext, useMemo } from 'react';
import { useSelector } from 'react-redux';
-import { getSelectedEntries } from '-/reducers/app';
import { getFirstRWLocation } from '-/reducers/locations';
import { PerspectiveIDs } from '-/perspectives';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
type TargetPathContextData = {
targetDirectoryPath: string;
@@ -38,13 +38,14 @@ export type TargetPathContextProviderProps = {
export const TargetPathContextProvider = ({
children
}: TargetPathContextProviderProps) => {
- const firstRWLocation = useSelector(getFirstRWLocation);
- const selectedEntries = useSelector(getSelectedEntries);
+ const { selectedEntries } = useSelectedEntriesContext();
const {
currentDirectoryPerspective,
currentDirectoryPath
} = useDirectoryContentContext();
+ const firstRWLocation = useSelector(getFirstRWLocation);
+
const context = useMemo(() => {
let targetDirectoryPath = currentDirectoryPath;
if (
diff --git a/app/components/menus/DirectoryMenu.tsx b/app/components/menus/DirectoryMenu.tsx
index 2eba154bf..42b680e65 100644
--- a/app/components/menus/DirectoryMenu.tsx
+++ b/app/components/menus/DirectoryMenu.tsx
@@ -30,11 +30,7 @@ import {
} from '@tagspaces/tagspaces-common/paths';
import { Pro } from '-/pro';
import PlatformIO from '-/services/platform-facade';
-import {
- actions as AppActions,
- AppDispatch,
- getSelectedEntries
-} from '-/reducers/app';
+import { actions as AppActions, AppDispatch } from '-/reducers/app';
import FileUploadContainer, {
FileUploadContainerRef
} from '-/components/FileUploadContainer';
@@ -52,6 +48,7 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
interface Props {
open: boolean;
@@ -71,15 +68,16 @@ interface Props {
function DirectoryMenu(props: Props) {
const { t } = useTranslation();
const { openEntry } = useOpenedEntryContext();
+ const { selectedEntries, setSelectedEntries } = useSelectedEntriesContext();
const { addTags } = useTaggingActionsContext();
const { currentLocation, readOnlyMode } = useCurrentLocationContext();
const { showNotification } = useNotificationContext();
const {
openDirectory,
currentDirectoryPath,
- setCurrentDirectoryPerspective
+ setCurrentDirectoryPerspective,
+ openCurrentDirectory
} = useDirectoryContentContext();
- const { reloadDirectory } = useIOActionsContext();
const { reflectCreateEntry } = useLocationIndexContext();
const fileUploadContainerRef = useRef<FileUploadContainerRef>(null);
const {
@@ -95,9 +93,6 @@ function DirectoryMenu(props: Props) {
perspectiveMode
} = props;
const directoryPath = props.directoryPath || currentDirectoryPath;
- const selectedEntries: Array<TS.FileSystemEntry> = useSelector(
- getSelectedEntries
- );
const locations: Array<TS.Location> = useSelector(getLocations);
const dispatch: AppDispatch = useDispatch();
@@ -117,10 +112,6 @@ function DirectoryMenu(props: Props) {
dispatch(AppActions.toggleDeleteMultipleEntriesDialog());
};
- const setSelectedEntries = selectedEntries => {
- dispatch(AppActions.setSelectedEntries(selectedEntries));
- };
-
const toggleProTeaser = slidePage => {
dispatch(AppActions.toggleProTeaser(slidePage));
};
@@ -409,7 +400,7 @@ Do you want to continue?`)
onClose,
t,
openDir,
- reloadDirectory,
+ openCurrentDirectory,
openRenameDirectoryDialog,
openMoveCopyFilesDialog,
showDeleteDirectoryDialog,
diff --git a/app/components/menus/FileMenu.tsx b/app/components/menus/FileMenu.tsx
index 0b0c84f2e..6c82f8d57 100644
--- a/app/components/menus/FileMenu.tsx
+++ b/app/components/menus/FileMenu.tsx
@@ -55,7 +55,10 @@ import { TS } from '-/tagspaces.namespace';
import { actions as AppActions, AppDispatch } from '-/reducers/app';
import { useSelector, useDispatch } from 'react-redux';
import { supportedImgs } from '-/services/thumbsgenerator';
-import { getPrefixTagContainer } from '-/reducers/settings';
+import {
+ getPrefixTagContainer,
+ getWarningOpeningFilesExternally
+} from '-/reducers/settings';
import {
OpenNewWindowIcon,
DeleteIcon,
@@ -68,6 +71,7 @@ import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
interface Props {
anchorEl: Element;
@@ -80,9 +84,7 @@ interface Props {
openMoveCopyFilesDialog: () => void;
openShareFilesDialog?: () => void;
openAddRemoveTagsDialog: () => void;
- openFileNatively: (path: string) => void;
selectedFilePath?: string;
- selectedEntries: Array<any>;
reorderTop?: () => void;
reorderBottom?: () => void;
onDuplicateFile?: (fileDirPath: string) => void;
@@ -96,8 +98,6 @@ function FileMenu(props: Props) {
openShareFilesDialog,
openAddRemoveTagsDialog,
onDuplicateFile,
- selectedEntries,
- openFileNatively,
reorderTop,
reorderBottom,
anchorEl,
@@ -110,22 +110,27 @@ function FileMenu(props: Props) {
const { t } = useTranslation();
const dispatch: AppDispatch = useDispatch();
+ const { selectedEntries } = useSelectedEntriesContext();
const { openEntry } = useOpenedEntryContext();
const { openDirectory } = useDirectoryContentContext();
const { showNotification } = useNotificationContext();
const { currentLocation, readOnlyMode } = useCurrentLocationContext();
const locations: Array<TS.Location> = useSelector(getLocations);
const prefixTagContainer = useSelector(getPrefixTagContainer);
+ const warningOpeningFilesExternally = useSelector(
+ getWarningOpeningFilesExternally
+ );
function generateFileLink() {
- const entryFromIndex = selectedEntries[0].locationID;
+ /*const entryFromIndex = selectedEntries[0].locationID;
const locationID = entryFromIndex
? selectedEntries[0].locationID
- : currentLocation.uuid;
+ : currentLocation.uuid;*/
const entryPath = selectedEntries[0].path;
- const tmpLoc = locations.find(location => location.uuid === locationID);
- const relativePath = getRelativeEntryPath(tmpLoc, entryPath);
- return generateSharingLink(locationID, relativePath);
+ /*const tmpLoc = locations.find(
+ location => location.uuid === locationID);*/
+ const relativePath = getRelativeEntryPath(currentLocation, entryPath);
+ return generateSharingLink(currentLocation.uuid, relativePath);
}
function showProperties() {
@@ -356,7 +361,11 @@ function FileMenu(props: Props) {
onClick={() => {
onClose();
if (selectedFilePath) {
- openFileNatively(selectedFilePath);
+ PlatformIO.openFile(
+ selectedFilePath,
+ warningOpeningFilesExternally
+ );
+ // openFileNatively(selectedFilePath);
}
}}
>
diff --git a/app/components/menus/TagMenu.tsx b/app/components/menus/TagMenu.tsx
index dbb2fe1c5..572c26258 100644
--- a/app/components/menus/TagMenu.tsx
+++ b/app/components/menus/TagMenu.tsx
@@ -17,7 +17,7 @@
*/
import React from 'react';
-import { useSelector, useDispatch } from 'react-redux';
+import { useSelector } from 'react-redux';
import ShowEntriesWithTagIcon from '@mui/icons-material/SearchOutlined';
import ApplyTagIcon from '@mui/icons-material/LocalOfferOutlined';
import Edit from '@mui/icons-material/Edit';
@@ -27,13 +27,12 @@ import ListItemText from '@mui/material/ListItemText';
import Menu from '@mui/material/Menu';
import MenuItem from '@mui/material/MenuItem';
import { getMaxSearchResults } from '-/reducers/settings';
-import { AppDispatch, getSelectedEntries } from '-/reducers/app';
import { TS } from '-/tagspaces.namespace';
import { useTranslation } from 'react-i18next';
import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
-import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
const isTagLibraryReadOnly =
window.ExtTagLibrary && window.ExtTagLibrary.length > 0;
@@ -58,11 +57,11 @@ function TagMenu(props: Props) {
} = props;
const { t } = useTranslation();
+ const { selectedEntries } = useSelectedEntriesContext();
const { addTags } = useTaggingActionsContext();
const { readOnlyMode } = useCurrentLocationContext();
const { setSearchQuery } = useDirectoryContentContext();
const maxSearchResults: number = useSelector(getMaxSearchResults);
- const selectedEntries = useSelector(getSelectedEntries);
function showFilesWithThisTag() {
if (selectedTag) {
diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsx
index 7231eda2c..d834f43b6 100644
--- a/app/containers/MainPage.tsx
+++ b/app/containers/MainPage.tsx
@@ -62,7 +62,6 @@ import {
isProgressOpened,
isDeleteMultipleEntriesDialogOpened,
isImportKanBanDialogOpened,
- getSelectedEntries,
currentUser,
isLocationDialogOpened,
isProTeaserVisible,
@@ -89,6 +88,7 @@ import { DescriptionContextProvider } from '-/hooks/DescriptionContextProvider';
import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { useFsActionsContext } from '-/hooks/useFsActionsContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
const drawerWidth = 320;
const body = document.getElementsByTagName('body')[0];
@@ -172,7 +172,7 @@ interface Props {
toggleOnboardingDialog: () => void; // needed by electron-menus
toggleProTeaser: () => void; // needed by electron-menus
// setLastSelectedEntry: (path: string) => void; // needed by electron-menus
- setSelectedEntries: (selectedEntries: Array<Object>) => void; // needed by electron-menus
+ // setSelectedEntries: (selectedEntries: Array<Object>) => void; // needed by electron-menus
openLocationManagerPanel: () => void;
openTagLibraryPanel: () => void;
// openSearchPanel: () => void;
@@ -188,12 +188,10 @@ interface Props {
isTagLibraryPanelOpened: boolean;
isSearchPanelOpened: boolean;
isHelpFeedbackPanelOpened: boolean;
- reflectCreateEntries: (fsEntries: Array<TS.FileSystemEntry>) => void;
onUploadProgress: (progress: Progress, response: any) => void;
isDeleteMultipleEntriesDialogOpened: boolean;
isImportKanBanDialogOpened: boolean;
toggleDeleteMultipleEntriesDialog: () => void;
- selectedEntries: Array<any>;
user: CognitoUserInterface;
}
@@ -316,7 +314,8 @@ function ProTeaserDialogAsync(props) {
function MainPage(props: Props) {
const { t } = useTranslation();
- const { deleteDirectory } = useFsActionsContext();
+ const { deleteDirectory, deleteFile } = useFsActionsContext();
+ const { selectedEntries, setSelectedEntries } = useSelectedEntriesContext();
const {
openLink,
openedEntries,
@@ -327,12 +326,11 @@ function MainPage(props: Props) {
openPrevFile
} = useOpenedEntryContext();
- const { deleteFile } = useFsActionsContext();
-
const {
loadParentDirectoryContent,
enterSearchMode,
- exitSearchMode
+ exitSearchMode,
+ setSearchQuery
} = useDirectoryContentContext();
const theme = useTheme();
const percent = useRef<number | undefined>(undefined);
@@ -411,7 +409,8 @@ function MainPage(props: Props) {
goForward,
openFsEntry,
openNextFile,
- openPrevFile
+ openPrevFile,
+ setSearchQuery
});
}, []);
@@ -689,7 +688,7 @@ function MainPage(props: Props) {
open={props.isSettingsDialogOpened}
onClose={toggleSettingsDialog}
/>
- {KanBanImportDialog && props.selectedEntries[0] && (
+ {KanBanImportDialog && selectedEntries[0] && (
<KanBanImportDialog
open={props.isImportKanBanDialogOpened}
onClose={props.toggleImportKanBanDialog}
@@ -701,10 +700,10 @@ function MainPage(props: Props) {
onClose={() => props.toggleDeleteMultipleEntriesDialog()}
title={t('core:deleteConfirmationTitle')}
content={t('core:deleteConfirmationContent')}
- list={props.selectedEntries.map(fsEntry => fsEntry.name)}
+ list={selectedEntries.map(fsEntry => fsEntry.name)}
confirmCallback={result => {
- if (result && props.selectedEntries) {
- const deletePromises = props.selectedEntries.map(fsEntry => {
+ if (result && selectedEntries) {
+ const deletePromises = selectedEntries.map(fsEntry => {
if (fsEntry.isFile) {
return deleteFile(fsEntry.path, fsEntry.uuid);
}
@@ -714,7 +713,7 @@ function MainPage(props: Props) {
.then(delResult => {
// console.debug(delResult);
if (delResult.some(del => del)) {
- props.setSelectedEntries([]);
+ setSelectedEntries([]);
} // TODO else { remove only deleted from setSelectedEntries}
return true;
})
@@ -833,7 +832,6 @@ function mapStateToProps(state) {
state
),
isImportKanBanDialogOpened: isImportKanBanDialogOpened(state),
- selectedEntries: getSelectedEntries(state),
user: currentUser(state)
};
}
@@ -865,10 +863,8 @@ function mapDispatchToProps(dispatch) {
toggleOnboardingDialog: AppActions.toggleOnboardingDialog,
toggleOpenLinkDialog: AppActions.toggleOpenLinkDialog,
toggleProTeaser: AppActions.toggleProTeaser,
- setSelectedEntries: AppActions.setSelectedEntries,
toggleShowUnixHiddenEntries: SettingsActions.toggleShowUnixHiddenEntries,
setMainVerticalSplitSize: SettingsActions.setMainVerticalSplitSize,
- reflectCreateEntries: AppActions.reflectCreateEntries,
openLocationManagerPanel: AppActions.openLocationManagerPanel,
openTagLibraryPanel: AppActions.openTagLibraryPanel,
// openSearchPanel: AppActions.openSearchPanel,
@@ -915,9 +911,7 @@ const areEqual = (prevProp, nextProp) =>
prevProp.isThirdPartyLibsDialogOpened &&
nextProp.isUploadProgressDialogOpened ===
prevProp.isUploadProgressDialogOpened &&
- nextProp.isImportKanBanDialogOpened === prevProp.isImportKanBanDialogOpened &&
- JSON.stringify(nextProp.selectedEntries) ===
- JSON.stringify(prevProp.selectedEntries);
+ nextProp.isImportKanBanDialogOpened === prevProp.isImportKanBanDialogOpened;
export default withDnDContext(
connect(mapStateToProps, mapDispatchToProps)(React.memo(MainPage, areEqual)) //translate(['core'], { wait: true })(React.memo(MainPage, areEqual)))
diff --git a/app/containers/Root.tsx b/app/containers/Root.tsx
index aae3825ac..2dafcbcc2 100644
--- a/app/containers/Root.tsx
+++ b/app/containers/Root.tsx
@@ -34,6 +34,10 @@ import { NotificationContextProvider } from '-/hooks/NotificationContextProvider
import { IOActionsContextProvider } from '-/hooks/IOActionsContextProvider';
import { TaggingActionsContextProvider } from '-/hooks/TaggingActionsContextProvider';
import { LocationIndexContextProvider } from '-/hooks/LocationIndexContextProvider';
+import {
+ SelectedEntryContext,
+ SelectedEntryContextProvider
+} from '-/hooks/SelectedEntryContextProvider';
type RootType = {
store: Store<{}>;
@@ -55,19 +59,21 @@ export default function Root({ store, persistor }: RootType) {
<App>
<NotificationContextProvider>
<CurrentLocationContextProvider>
- <DirectoryContentContextProvider>
- <LocationIndexContextProvider>
- <OpenedEntryContextProvider>
- <FsActionsContextProvider>
- <IOActionsContextProvider>
- <TaggingActionsContextProvider>
- <MainPage />
- </TaggingActionsContextProvider>
- </IOActionsContextProvider>
- </FsActionsContextProvider>
- </OpenedEntryContextProvider>
- </LocationIndexContextProvider>
- </DirectoryContentContextProvider>
+ <SelectedEntryContextProvider>
+ <DirectoryContentContextProvider>
+ <LocationIndexContextProvider>
+ <OpenedEntryContextProvider>
+ <FsActionsContextProvider>
+ <IOActionsContextProvider>
+ <TaggingActionsContextProvider>
+ <MainPage />
+ </TaggingActionsContextProvider>
+ </IOActionsContextProvider>
+ </FsActionsContextProvider>
+ </OpenedEntryContextProvider>
+ </LocationIndexContextProvider>
+ </DirectoryContentContextProvider>
+ </SelectedEntryContextProvider>
</CurrentLocationContextProvider>
</NotificationContextProvider>
</App>
diff --git a/app/hooks/CurrentLocationContextProvider.tsx b/app/hooks/CurrentLocationContextProvider.tsx
index 7a5fca59f..eeb1f4e70 100644
--- a/app/hooks/CurrentLocationContextProvider.tsx
+++ b/app/hooks/CurrentLocationContextProvider.tsx
@@ -103,7 +103,6 @@ export const CurrentLocationContextProvider = ({
const dispatch: AppDispatch = useDispatch();
const { t } = useTranslation();
const { showNotification } = useNotificationContext();
-
const [currentLocation, setCurrentLocation] = useState<TS.Location>(
undefined
);
@@ -244,7 +243,7 @@ export const CurrentLocationContextProvider = ({
return locationPersistTagsInSidecarFile;
}
return settingsPersistTagsInSidecarFile;
- }, [currentLocation]);
+ }, [currentLocation, settingsPersistTagsInSidecarFile]);
function changeLocation(location: TS.Location) {
if (!currentLocation || location.uuid !== currentLocation.uuid) {
@@ -344,7 +343,6 @@ export const CurrentLocationContextProvider = ({
if (location.uuid === locationId) {
// location needed evtl. to unwatch many loc. root folders if available
setCurrentLocation(undefined);
- dispatch(AppActions.setSelectedEntries([]));
}
clearAllURLParams();
return true;
@@ -355,7 +353,6 @@ export const CurrentLocationContextProvider = ({
function closeAllLocations() {
// location needed evtl. to unwatch many loc. root folders if available
setCurrentLocation(undefined);
- dispatch(AppActions.setSelectedEntries([]));
clearAllURLParams();
return true;
}
@@ -393,6 +390,7 @@ export const CurrentLocationContextProvider = ({
};
}, [
currentLocation,
+ persistTagsInSidecarFile,
skipInitialDirList.current,
locationDirectoryContextMenuAnchorEl
]);
diff --git a/app/hooks/DescriptionContextProvider.tsx b/app/hooks/DescriptionContextProvider.tsx
index b776c3793..b7b4f989e 100644
--- a/app/hooks/DescriptionContextProvider.tsx
+++ b/app/hooks/DescriptionContextProvider.tsx
@@ -34,6 +34,7 @@ import { useTranslation } from 'react-i18next';
import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
type DescriptionContextData = {
description: string;
@@ -59,7 +60,7 @@ export const DescriptionContextProvider = ({
children
}: DescriptionContextProviderProps) => {
const { t } = useTranslation();
- const dispatch: AppDispatch = useDispatch();
+ const { setSelectedEntries } = useSelectedEntriesContext();
const {
openedEntries,
addToEntryContainer,
@@ -89,7 +90,7 @@ export const DescriptionContextProvider = ({
) {
// handle not saved changes
addToEntryContainer({ ...openedFile.current, editMode: false });
- dispatch(AppActions.setSelectedEntries([]));
+ setSelectedEntries([]);
saveDescriptionConfirmOpened(true);
} else {
openedFile.current = openedEntries[0];
diff --git a/app/hooks/DirectoryContentContextProvider.tsx b/app/hooks/DirectoryContentContextProvider.tsx
index 10005d1b3..15301df7a 100644
--- a/app/hooks/DirectoryContentContextProvider.tsx
+++ b/app/hooks/DirectoryContentContextProvider.tsx
@@ -29,8 +29,7 @@ import { locationType } from '@tagspaces/tagspaces-common/misc';
import {
actions as AppActions,
AppDispatch,
- getEditedEntryPaths,
- getSelectedEntries
+ getEditedEntryPaths
} from '-/reducers/app';
import { TS } from '-/tagspaces.namespace';
import { useTranslation } from 'react-i18next';
@@ -54,6 +53,7 @@ import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import useFirstRender from '-/utils/useFirstRender';
import { useNotificationContext } from '-/hooks/useNotificationContext';
import { loadCurrentDirMeta } from '-/services/meta-loader';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
type DirectoryContentContextData = {
currentDirectoryEntries: TS.FileSystemEntry[];
@@ -72,6 +72,7 @@ type DirectoryContentContextData = {
isMetaFolderExist: boolean;
searchQuery: TS.SearchQuery;
isSearchMode: boolean;
+ addDirectoryEntries: (entries: TS.FileSystemEntry[]) => void;
setSearchQuery: (sQuery: TS.SearchQuery) => void;
loadParentDirectoryContent: () => void;
loadDirectoryContent: (
@@ -116,6 +117,7 @@ export const DirectoryContentContext = createContext<
isMetaFolderExist: false,
searchQuery: {},
isSearchMode: false,
+ addDirectoryEntries: undefined,
setSearchQuery: () => {},
loadParentDirectoryContent: () => {},
loadDirectoryContent: undefined,
@@ -152,7 +154,8 @@ export const DirectoryContentContextProvider = ({
skipInitialDirList
} = useCurrentLocationContext();
const { showNotification, hideNotifications } = useNotificationContext();
- const selectedEntries = useSelector(getSelectedEntries);
+
+ const { selectedEntries, setSelectedEntries } = useSelectedEntriesContext();
//const useGenerateThumbnails = useSelector(getUseGenerateThumbnails);
const showUnixHiddenEntries = useSelector(getShowUnixHiddenEntries);
const editedEntryPaths = useSelector(getEditedEntryPaths);
@@ -278,16 +281,23 @@ export const DirectoryContentContextProvider = ({
if (isSearchMode.current) {
exitSearchMode();
}
- const currentLocationPath = normalizePath(currentLocation.path);
+ const currentLocationPath = normalizePath(
+ PlatformIO.getLocationPath(currentLocation)
+ );
// dispatch(actions.setIsLoading(true));
- if (currentDirectoryPath.current) {
+ if (currentDirectoryPath.current !== undefined) {
const parentDirectory = extractParentDirectoryPath(
currentDirectoryPath.current,
PlatformIO.getDirSeparator()
);
- // console.log('parentDirectory: ' + parentDirectory + ' - currentLocationPath: ' + currentLocationPath);
+ console.log(
+ 'parentDirectory: ' +
+ parentDirectory +
+ ' - currentLocationPath: ' +
+ currentLocationPath
+ );
if (parentDirectory.includes(currentLocationPath)) {
openDirectory(parentDirectory);
} else {
@@ -374,7 +384,7 @@ export const DirectoryContentContextProvider = ({
// dispatch(actions.setIsLoading(true));
if (selectedEntries.length > 0) {
- dispatch(AppActions.setSelectedEntries([]));
+ setSelectedEntries([]);
}
if (loadDirMeta) {
const metaDirectory = getMetaDirectoryPath(directoryPath);
@@ -477,7 +487,7 @@ export const DirectoryContentContextProvider = ({
}
function openDirectory(dirPath: string): Promise<boolean> {
- if (dirPath) {
+ if (dirPath !== undefined) {
return loadDirectoryContent(dirPath, true).then(dirEntries => {
if (dirEntries) {
return loadCurrentDirMeta(dirPath, dirEntries).then(entries => {
@@ -523,7 +533,7 @@ export const DirectoryContentContextProvider = ({
isSearchMode.current = false;
- if (
+ /*if (
currentDirectoryPath.current &&
currentDirectoryPath.current.startsWith('./')
) {
@@ -531,9 +541,9 @@ export const DirectoryContentContextProvider = ({
currentDirectoryPath.current = PlatformIO.resolveFilePath(
currentDirectoryPath.current
);
- } else {
- currentDirectoryPath.current = directoryPath;
- }
+ } else {*/
+ currentDirectoryPath.current = directoryPath;
+ //}
setCurrentDirectoryEntries(directoryContent);
return directoryContent;
}
@@ -636,6 +646,13 @@ export const DirectoryContentContextProvider = ({
reload: boolean = true
) {
currentPerspective.current = perspective;
+ setSelectedEntries([]);
+ /*if (PerspectiveIDs.KANBAN === perspective) {
+ // many items can't be selected in KanBan
+ if (selectedEntries.length > 1) {
+ setSelectedEntries([selectedEntries[selectedEntries.length - 1]]);
+ }
+ }*/
if (reload) {
forceUpdate();
}
@@ -654,6 +671,10 @@ export const DirectoryContentContextProvider = ({
currentDirectoryFiles.current = files;
}
+ function addDirectoryEntries(entries: TS.FileSystemEntry[]) {
+ setCurrentDirectoryEntries([...currentDirectoryEntries, ...entries]);
+ }
+
function setDirectoryMeta(meta: TS.FileSystemEntryMeta) {
directoryMeta.current = meta;
isMetaLoaded.current = true;
@@ -681,6 +702,8 @@ export const DirectoryContentContextProvider = ({
isMetaFolderExist: isMetaFolderExist.current,
searchQuery: searchQuery.current,
isSearchMode: isSearchMode.current,
+ setCurrentDirectoryEntries,
+ updateCurrentDirEntry,
setSearchQuery,
loadDirectoryContent,
loadParentDirectoryContent,
@@ -692,7 +715,7 @@ export const DirectoryContentContextProvider = ({
setCurrentDirectoryColor,
setCurrentDirectoryDirs,
setCurrentDirectoryFiles,
- updateCurrentDirEntry,
+ addDirectoryEntries,
updateCurrentDirEntries,
updateThumbnailUrl,
setDirectoryMeta,
diff --git a/app/hooks/FsActionsContextProvider.tsx b/app/hooks/FsActionsContextProvider.tsx
index 67b6b01ec..3b4cbf627 100644
--- a/app/hooks/FsActionsContextProvider.tsx
+++ b/app/hooks/FsActionsContextProvider.tsx
@@ -29,7 +29,10 @@ import {
getThumbFileLocationForFile
} from '@tagspaces/tagspaces-common/paths';
import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
-import { getUseTrashCan } from '-/reducers/settings';
+import {
+ getUseTrashCan,
+ getWarningOpeningFilesExternally
+} from '-/reducers/settings';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import {
deleteFilesPromise,
@@ -38,6 +41,7 @@ import {
} from '-/services/utils-io';
import { useNotificationContext } from '-/hooks/useNotificationContext';
import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
type FsActionsContextData = {
renameDirectory: (
@@ -48,6 +52,7 @@ type FsActionsContextData = {
deleteDirectory: (directoryPath: string) => Promise<boolean>;
renameFile: (filePath: string, newFilePath: string) => Promise<boolean>;
deleteFile: (filePath: string, uuid: string) => Promise<boolean>;
+ openFileNatively: (selectedFile?: string) => void;
};
export const FsActionsContext = createContext<FsActionsContextData>({
@@ -55,7 +60,8 @@ export const FsActionsContext = createContext<FsActionsContextData>({
createDirectory: () => Promise.resolve(false),
deleteDirectory: () => Promise.resolve(false),
renameFile: () => Promise.resolve(false),
- deleteFile: () => Promise.resolve(false)
+ deleteFile: () => Promise.resolve(false),
+ openFileNatively: undefined
});
export type FsActionsContextProviderProps = {
@@ -66,6 +72,7 @@ export const FsActionsContextProvider = ({
children
}: FsActionsContextProviderProps) => {
const { t } = useTranslation();
+ const { setSelectedEntries, selectedEntries } = useSelectedEntriesContext();
const {
openedEntries,
reflectRenameDirectory,
@@ -84,6 +91,9 @@ export const FsActionsContextProvider = ({
const { showNotification } = useNotificationContext();
const dispatch: AppDispatch = useDispatch();
const useTrashCan = useSelector(getUseTrashCan);
+ const warningOpeningFilesExternally = useSelector(
+ getWarningOpeningFilesExternally
+ );
function renameDirectory(directoryPath: string, newDirectoryName: string) {
return PlatformIO.renameDirectoryPromise(directoryPath, newDirectoryName)
@@ -97,6 +107,7 @@ export const FsActionsContextProvider = ({
reflectRenameEntry(directoryPath, newDirPath);
dispatch(AppActions.reflectRenameEntry(directoryPath, newDirPath));
}
+ setSelectedEntries([]);
showNotification(
`Renaming directory ${extractDirectoryName(
@@ -239,6 +250,7 @@ export const FsActionsContextProvider = ({
dispatch(
AppActions.reflectRenameEntry(filePath, newFilePathFromPromise)
);
+ setSelectedEntries([]);
console.info(
'Renaming meta file and thumb successful from ' +
filePath +
@@ -252,6 +264,7 @@ export const FsActionsContextProvider = ({
dispatch(
AppActions.reflectRenameEntry(filePath, newFilePathFromPromise)
);
+ setSelectedEntries([]);
console.warn(
'Renaming meta file and thumb failed from ' +
filePath +
@@ -333,13 +346,30 @@ export const FsActionsContextProvider = ({
});
}
+ function openFileNatively(selectedFile?: string) {
+ // todo reload selectedEntries or find better place for this function
+ if (selectedFile === undefined) {
+ if (selectedEntries && selectedEntries.length > 0) {
+ const fsEntry = selectedEntries[selectedEntries.length - 1];
+ if (fsEntry.isFile) {
+ PlatformIO.openFile(fsEntry.path, warningOpeningFilesExternally);
+ } else {
+ PlatformIO.openDirectory(fsEntry.path);
+ }
+ }
+ } else {
+ PlatformIO.openFile(selectedFile, warningOpeningFilesExternally);
+ }
+ }
+
const context = useMemo(() => {
return {
renameDirectory,
createDirectory,
deleteDirectory,
renameFile,
- deleteFile
+ deleteFile,
+ openFileNatively
};
}, [openedEntries]);
diff --git a/app/hooks/IOActionsContextProvider.tsx b/app/hooks/IOActionsContextProvider.tsx
index 191aa0b32..b00c93558 100644
--- a/app/hooks/IOActionsContextProvider.tsx
+++ b/app/hooks/IOActionsContextProvider.tsx
@@ -51,7 +51,7 @@ import {
loadJSONString
} from '@tagspaces/tagspaces-common/utils-io';
import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';
-import { loadCurrentDirMeta } from '-/services/meta-loader';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
type extractOptions = {
EXIFGeo?: boolean;
@@ -98,7 +98,7 @@ type IOActionsContextData = {
onUploadProgress?: (progress: Progress, abort, fileName?) => void,
uploadMeta?: boolean
) => Promise<TS.FileSystemEntry[]>;
- reloadDirectory: (dirPath?: string) => Promise<boolean>;
+ //reloadDirectory: (dirPath?: string) => Promise<boolean>;
};
export const IOActionsContext = createContext<IOActionsContextData>({
@@ -109,8 +109,8 @@ export const IOActionsContext = createContext<IOActionsContextData>({
copyFiles: () => Promise.resolve(false),
downloadFile: () => Promise.resolve(undefined),
uploadFilesAPI: () => Promise.resolve([]),
- uploadFiles: () => Promise.resolve([]),
- reloadDirectory: () => Promise.resolve(false)
+ uploadFiles: () => Promise.resolve([])
+ //reloadDirectory: () => Promise.resolve(false)
});
export type IOActionsContextProviderProps = {
@@ -126,8 +126,10 @@ export const IOActionsContextProvider = ({
const {
currentDirectoryEntries,
currentDirectoryPath,
- openDirectory
+ openDirectory,
+ addDirectoryEntries
} = useDirectoryContentContext();
+ const { setSelectedEntries } = useSelectedEntriesContext();
const {
reflectDeleteEntry,
reflectCreateEntry,
@@ -393,7 +395,10 @@ export const IOActionsContextProvider = ({
})
.then((fsEntry: TS.FileSystemEntry) => {
reflectCreateEntry(fsEntry);
- dispatch(AppActions.reflectCreateEntryObj(fsEntry));
+ addDirectoryEntries([fsEntry]);
+ dispatch(AppActions.reflectCreateEntries([fsEntry]));
+ setSelectedEntries([fsEntry]);
+
return fsEntry;
});
//.catch(e => console.log(e));
@@ -754,9 +759,11 @@ export const IOActionsContextProvider = ({
});
}
- function reloadDirectory(directoryPath?: string) {
- return openDirectory(directoryPath ? directoryPath : currentDirectoryPath);
- }
+ /*function reloadDirectory(directoryPath?: string) {
+ return openDirectory(
+ directoryPath === undefined ? currentDirectoryPath : directoryPath
+ );
+ }*/
const context = useMemo(() => {
return {
@@ -767,8 +774,7 @@ export const IOActionsContextProvider = ({
copyFiles,
downloadFile,
uploadFilesAPI,
- uploadFiles,
- reloadDirectory
+ uploadFiles
};
}, [currentDirectoryEntries]);
diff --git a/app/hooks/OpenedEntryContextProvider.tsx b/app/hooks/OpenedEntryContextProvider.tsx
index 31ee51fe1..bf3f1fcb5 100644
--- a/app/hooks/OpenedEntryContextProvider.tsx
+++ b/app/hooks/OpenedEntryContextProvider.tsx
@@ -28,7 +28,6 @@ import {
actions as AppActions,
AppDispatch,
getEditedEntryPaths,
- getLastSelectedEntry,
OpenedEntry
} from '-/reducers/app';
import { Pro } from '-/pro';
@@ -75,6 +74,7 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
type OpenedEntryContextData = {
openedEntries: OpenedEntry[];
@@ -148,13 +148,12 @@ export const OpenedEntryContextProvider = ({
setCurrentDirectoryPerspective,
updateCurrentDirEntry
} = useDirectoryContentContext();
+
+ const { selectedEntries, setSelectedEntries } = useSelectedEntriesContext();
const { showNotification } = useNotificationContext();
const { openLocation, currentLocation } = useCurrentLocationContext();
const { reflectCreateEntry } = useLocationIndexContext();
const supportedFileTypes = useSelector(getSupportedFileTypes);
- const lastSelectedEntry: TS.FileSystemEntry = useSelector(
- getLastSelectedEntry
- );
const locations: TS.Location[] = useSelector(getLocations);
const historyKeys = Pro && Pro.history ? Pro.history.historyKeys : {};
const fileOpenHistory = useSelector(
@@ -206,7 +205,7 @@ export const OpenedEntryContextProvider = ({
}*/
}, []);
- useEffect(() => {
+ /*useEffect(() => {
if (
!firstRender &&
havePrevOpenedFile.current
@@ -234,7 +233,7 @@ export const OpenedEntryContextProvider = ({
}
}
havePrevOpenedFile.current = openedEntries.length > 0;
- }, [openedEntries]);
+ }, [openedEntries]);*/
/**
* HANDLE REFLECT_RENAME_ENTRY
@@ -566,11 +565,12 @@ export const OpenedEntryContextProvider = ({
function openFsEntry(fsEntry?: TS.FileSystemEntry, showDetails = false) {
dispatch(SettingsActions.setShowDetails(showDetails));
if (fsEntry === undefined) {
- if (lastSelectedEntry === undefined) {
- return;
- }
- if (!lastSelectedEntry.isFile) {
- openDirectory(lastSelectedEntry.path); //, false);
+ if (selectedEntries && selectedEntries.length > 0) {
+ const lastSelectedEntry = selectedEntries[selectedEntries.length - 1];
+ if (!lastSelectedEntry.isFile) {
+ return openDirectory(lastSelectedEntry.path); //, false);
+ }
+ } else {
return;
}
}
@@ -689,13 +689,15 @@ export const OpenedEntryContextProvider = ({
function openNextFile(path?: string) {
const nextFile = getNextFile(
path,
- lastSelectedEntry ? lastSelectedEntry.path : undefined,
+ selectedEntries && selectedEntries.length > 0
+ ? selectedEntries[selectedEntries.length - 1].path
+ : undefined,
currentDirectoryEntries
);
if (nextFile !== undefined) {
openFsEntry(nextFile);
// dispatch(actions.setLastSelectedEntry(nextFile.path));
- dispatch(AppActions.setSelectedEntries([nextFile]));
+ setSelectedEntries([nextFile]);
return nextFile;
}
}
@@ -703,13 +705,15 @@ export const OpenedEntryContextProvider = ({
function openPrevFile(path?: string) {
const prevFile = getPrevFile(
path,
- lastSelectedEntry ? lastSelectedEntry.path : undefined,
+ selectedEntries && selectedEntries.length > 0
+ ? selectedEntries[selectedEntries.length - 1].path
+ : undefined,
currentDirectoryEntries
);
if (prevFile !== undefined) {
openFsEntry(prevFile);
// dispatch(actions.setLastSelectedEntry(prevFile.path));
- dispatch(AppActions.setSelectedEntries([prevFile]));
+ setSelectedEntries([prevFile]);
}
}
diff --git a/app/hooks/SelectedEntryContextProvider.tsx b/app/hooks/SelectedEntryContextProvider.tsx
new file mode 100644
index 000000000..26d53c1a5
--- /dev/null
+++ b/app/hooks/SelectedEntryContextProvider.tsx
@@ -0,0 +1,93 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2023-present TagSpaces UG (haftungsbeschraenkt)
+ *
+ * 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, { createContext, useEffect, useMemo, useState } from 'react';
+import { TS } from '-/tagspaces.namespace';
+import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
+import useFirstRender from '-/utils/useFirstRender';
+
+type SelectedEntryContextData = {
+ selectedEntries: TS.FileSystemEntry[];
+ lastSelectedEntryPath: string;
+ setSelectedEntries(entries: TS.FileSystemEntry[]);
+};
+
+export const SelectedEntryContext = createContext<SelectedEntryContextData>({
+ selectedEntries: undefined,
+ lastSelectedEntryPath: undefined,
+ setSelectedEntries: undefined
+});
+
+export type SelectedEntryContextProviderProps = {
+ children: React.ReactNode;
+};
+
+export const SelectedEntryContextProvider = ({
+ children
+}: SelectedEntryContextProviderProps) => {
+ const { currentLocation } = useCurrentLocationContext();
+ const [selectedEntries, setSelectedEntries] = useState<TS.FileSystemEntry[]>(
+ []
+ );
+ const firstRender = useFirstRender();
+
+ useEffect(() => {
+ if (!firstRender && !currentLocation) {
+ setSelectedEntries([]);
+ }
+ }, [currentLocation]);
+ //const lastSelectedEntry = useRef<TS.FileSystemEntry>(undefined);
+
+ /*function getLastSelectedEntry() {
+ if (selectedEntries && selectedEntries.length > 0) {
+ return selectedEntries[selectedEntries.length - 1];
+ }
+ return undefined;
+ }*/
+ /*const setSelectedEntries = (entries: TS.FileSystemEntry[]) => {
+ if (JSON.stringify(selectedEntries) !== JSON.stringify(entries)) {
+ setSelectedEntriesInt(entries);
+ }
+ };*/
+
+ const lastSelectedEntryPath = useMemo(() => {
+ if (selectedEntries && selectedEntries.length > 0) {
+ return selectedEntries[selectedEntries.length - 1].path;
+ }
+ return undefined;
+ }, [selectedEntries]);
+
+ /*function getSelectedEntriesLength() {
+ return selectedEntries ? selectedEntries.length : 0;
+ }*/
+
+ const context = useMemo(() => {
+ return {
+ selectedEntries,
+ //lastSelectedEntry: lastSelectedEntry.current,
+ lastSelectedEntryPath,
+ setSelectedEntries
+ };
+ }, [selectedEntries]);
+
+ return (
+ <SelectedEntryContext.Provider value={context}>
+ {children}
+ </SelectedEntryContext.Provider>
+ );
+};
diff --git a/app/hooks/useSelectedEntriesContext.tsx b/app/hooks/useSelectedEntriesContext.tsx
new file mode 100644
index 000000000..e568bbc2a
--- /dev/null
+++ b/app/hooks/useSelectedEntriesContext.tsx
@@ -0,0 +1,23 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2023-present TagSpaces UG (haftungsbeschraenkt)
+ *
+ * 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 { SelectedEntryContext } from './SelectedEntryContextProvider';
+
+export const useSelectedEntriesContext = () => useContext(SelectedEntryContext);
diff --git a/app/perspectives/grid-perspective/components/CellContent.tsx b/app/perspectives/grid-perspective/components/CellContent.tsx
index e4a962581..43533af30 100644
--- a/app/perspectives/grid-perspective/components/CellContent.tsx
+++ b/app/perspectives/grid-perspective/components/CellContent.tsx
@@ -66,6 +66,7 @@ import {
import { useTranslation } from 'react-i18next';
import { useTaggingActionsContext } from '-/hooks/useTaggingActionsContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
const maxDescriptionPreviewLength = 100;
@@ -76,7 +77,6 @@ interface Props {
entrySize: string;
style?: any;
thumbnailMode: any;
- selectedEntries: Array<TS.FileSystemEntry>;
selectEntry: (fsEntry: TS.FileSystemEntry) => void;
deselectEntry: (fsEntry: TS.FileSystemEntry) => void;
showTags: boolean;
@@ -94,7 +94,6 @@ function CellContent(props: Props) {
fsEntry,
entrySize,
thumbnailMode,
- selectedEntries,
handleTagMenu,
layoutType,
handleGridContextMenu,
@@ -109,6 +108,7 @@ function CellContent(props: Props) {
const { t } = useTranslation();
const theme = useTheme();
+ const { selectedEntries } = useSelectedEntriesContext();
const { addTags, editTagForEntry } = useTaggingActionsContext();
const { readOnlyMode } = useCurrentLocationContext();
const supportedFileTypes = useSelector(getSupportedFileTypes);
@@ -521,7 +521,6 @@ function CellContent(props: Props) {
entryPath={entryPath}
addTags={handleAddTags}
handleTagMenu={handleTagMenu}
- selectedEntries={selectedEntries}
/>
) : (
<TagContainerDnd
@@ -543,7 +542,7 @@ function CellContent(props: Props) {
}
return tagContainer;
});
- }, [entryTags, readOnlyMode, reorderTags, entryPath, selectedEntries]);
+ }, [entryTags, readOnlyMode, reorderTags, entryPath]);
let entryHeight = 130;
if (entrySize === 'small') {
diff --git a/app/perspectives/grid-perspective/components/GridPagination.tsx b/app/perspectives/grid-perspective/components/GridPagination.tsx
index ec25c87e0..4b301864f 100644
--- a/app/perspectives/grid-perspective/components/GridPagination.tsx
+++ b/app/perspectives/grid-perspective/components/GridPagination.tsx
@@ -29,8 +29,7 @@ import AppConfig from '-/AppConfig';
import { extractDirectoryName } from '@tagspaces/tagspaces-common/paths';
import {
getLastBackgroundImageChange,
- getLastThumbnailImageChange,
- getLastSelectedEntryPath
+ getLastThumbnailImageChange
} from '-/reducers/app';
import EntryIcon from '-/components/EntryIcon';
import TagsPreview from '-/components/TagsPreview';
@@ -51,6 +50,8 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { usePaginationContext } from '-/hooks/usePaginationContext';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
+import { useFsActionsContext } from '-/hooks/useFsActionsContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
interface Props {
style?: any;
@@ -89,8 +90,6 @@ interface Props {
lastThumbnailImageChange: any;
setSelectedEntries: (selectedEntries: Array<TS.FileSystemEntry>) => void;
singleClickAction: string;
- lastSelectedEntryPath: string;
- openFileNatively: (path?: string) => void;
setFileContextMenuAnchorEl: (HTMLElement) => void;
setDirContextMenuAnchorEl: (HTMLElement) => void;
clearSelection: () => void;
@@ -111,9 +110,7 @@ function GridPagination(props: Props) {
currentDirectoryPath,
lastThumbnailImageChange,
openRenameEntryDialog,
- lastSelectedEntryPath,
lastBackgroundImageChange,
- openFileNatively,
setFileContextMenuAnchorEl,
setDirContextMenuAnchorEl,
gridPageLimit,
@@ -122,8 +119,10 @@ function GridPagination(props: Props) {
clearSelection,
files
} = props;
+ const { lastSelectedEntryPath } = useSelectedEntriesContext();
const { openEntry } = useOpenedEntryContext();
const { moveFiles } = useIOActionsContext();
+ const { openFileNatively } = useFsActionsContext();
const { showNotification } = useNotificationContext();
const { readOnlyMode, currentLocation } = useCurrentLocationContext();
const {
@@ -487,8 +486,7 @@ function GridPagination(props: Props) {
function mapStateToProps(state) {
return {
lastBackgroundImageChange: getLastBackgroundImageChange(state),
- lastThumbnailImageChange: getLastThumbnailImageChange(state),
- lastSelectedEntryPath: getLastSelectedEntryPath(state)
+ lastThumbnailImageChange: getLastThumbnailImageChange(state)
};
}
diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsx
index cd9013d71..ccfa80f06 100644
--- a/app/perspectives/grid-perspective/components/MainContainer.tsx
+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx
@@ -28,12 +28,7 @@ import EntryTagMenu from '-/components/menus/EntryTagMenu';
import AddRemoveTagsDialog from '-/components/dialogs/AddRemoveTagsDialog';
import MoveCopyFilesDialog from '-/components/dialogs/MoveCopyFilesDialog';
import TagDropContainer from '-/components/TagDropContainer';
-import {
- actions as AppActions,
- AppDispatch,
- getLastSelectedEntryPath,
- getSelectedEntries
-} from '-/reducers/app';
+import { actions as AppActions, AppDispatch } from '-/reducers/app';
import CellContent from './CellContent';
import MainToolbar from './MainToolbar';
import SortingMenu from './SortingMenu';
@@ -53,6 +48,8 @@ import { openURLExternally } from '-/services/utils-io';
import { useSortedDirContext } from '-/perspectives/grid-perspective/hooks/useSortedDirContext';
import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
+import { useFsActionsContext } from '-/hooks/useFsActionsContext';
interface Props {
openRenameEntryDialog: () => void;
@@ -81,6 +78,7 @@ function GridPerspective(props: Props) {
currentDirectoryPath,
setDirectoryMeta
} = useDirectoryContentContext();
+ const { openFileNatively } = useFsActionsContext();
const dispatch: AppDispatch = useDispatch();
const {
@@ -91,10 +89,11 @@ function GridPerspective(props: Props) {
setOrderBy
} = useSortedDirContext();
const desktopMode = useSelector(getDesktopMode);
- const selectedEntries: Array<TS.FileSystemEntry> = useSelector(
- getSelectedEntries
- );
- const lastSelectedEntryPath = useSelector(getLastSelectedEntryPath);
+ const {
+ selectedEntries,
+ setSelectedEntries,
+ lastSelectedEntryPath
+ } = useSelectedEntriesContext();
const keyBindings = useSelector(getKeyBindingObject);
//const searchFilter: string = useSelector(getSearchFilter);
/*const editedEntryPaths: Array<TS.EditedEntryPath> = useSelector(
@@ -106,11 +105,7 @@ function GridPerspective(props: Props) {
const selected = showDirectories.current
? entries
: entries.filter(entry => entry.isFile);
- dispatch(AppActions.setSelectedEntries(selected));
- };
-
- const handleOpenFileNatively = (path?: string) => {
- dispatch(AppActions.openFileNatively(path));
+ setSelectedEntries(selected);
};
const isLocal =
@@ -224,7 +219,7 @@ function GridPerspective(props: Props) {
);
// 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);
+ const [ignored, forceUpdate] = useReducer(x => x + 1, 0, undefined);
const firstRender = useFirstRender();
useEffect(() => {
@@ -551,7 +546,7 @@ function GridPerspective(props: Props) {
openEntry();
},
openFileExternally: () => {
- handleOpenFileNatively();
+ openFileNatively();
}
};
@@ -612,7 +607,6 @@ function GridPerspective(props: Props) {
entrySize={entrySize.current}
isLast={isLast}
thumbnailMode={thumbnailMode.current}
- selectedEntries={selectedEntries}
selectEntry={selectEntry}
deselectEntry={deselectEntry}
handleTagMenu={handleTagMenu}
@@ -687,7 +681,6 @@ function GridPerspective(props: Props) {
selectedEntries={selectedEntries}
setSelectedEntries={handleSetSelectedEntries}
singleClickAction={singleClickAction.current}
- openFileNatively={handleOpenFileNatively}
setFileContextMenuAnchorEl={setFileContextMenuAnchorEl}
setDirContextMenuAnchorEl={setDirContextMenuAnchorEl}
clearSelection={clearSelection}
@@ -697,7 +690,6 @@ function GridPerspective(props: Props) {
<AddRemoveTagsDialog
open={isAddRemoveTagsDialogOpened}
onClose={() => setIsAddRemoveTagsDialogOpened(false)}
- selectedEntries={selectedEntries}
/>
)}
{isAddTagDialogOpened !== undefined && (
@@ -774,11 +766,9 @@ function GridPerspective(props: Props) {
: undefined
}
openAddRemoveTagsDialog={openAddRemoveTagsDialog}
- openFileNatively={handleOpenFileNatively}
selectedFilePath={
lastSelectedEntryPath ? lastSelectedEntryPath : currentDirectoryPath
}
- selectedEntries={selectedEntries}
/>
)}
{/* {Boolean(dirContextMenuAnchorEl) && ( // todo move dialogs from DirectoryMenu */}
diff --git a/app/perspectives/grid-perspective/components/MainToolbar.tsx b/app/perspectives/grid-perspective/components/MainToolbar.tsx
index a92af1ed6..25029b38a 100644
--- a/app/perspectives/grid-perspective/components/MainToolbar.tsx
+++ b/app/perspectives/grid-perspective/components/MainToolbar.tsx
@@ -38,11 +38,7 @@ import { Pro } from '-/pro';
import { ProTooltip } from '-/components/HelperComponents';
import { getKeyBindingObject } from '-/reducers/settings';
import { TS } from '-/tagspaces.namespace';
-import {
- actions as AppActions,
- AppDispatch,
- getSelectedEntries
-} from '-/reducers/app';
+import { actions as AppActions, AppDispatch } from '-/reducers/app';
import {
classes,
GridStyles
@@ -52,6 +48,7 @@ import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
interface Props {
prefixDataTID?: string;
@@ -82,9 +79,7 @@ function MainToolbar(props: Props) {
loadParentDirectoryContent,
currentDirectoryPath
} = useDirectoryContentContext();
- const selectedEntries: Array<TS.FileSystemEntry> = useSelector(
- getSelectedEntries
- );
+ const { selectedEntries } = useSelectedEntriesContext();
const keyBindings = useSelector(getKeyBindingObject);
const dispatch: AppDispatch = useDispatch();
const { readOnlyMode } = useCurrentLocationContext();
diff --git a/app/perspectives/list/components/MainContainer.tsx b/app/perspectives/list/components/MainContainer.tsx
index 288ad3c61..00f7f8a38 100644
--- a/app/perspectives/list/components/MainContainer.tsx
+++ b/app/perspectives/list/components/MainContainer.tsx
@@ -28,12 +28,7 @@ import EntryTagMenu from '-/components/menus/EntryTagMenu';
import AddRemoveTagsDialog from '-/components/dialogs/AddRemoveTagsDialog';
import MoveCopyFilesDialog from '-/components/dialogs/MoveCopyFilesDialog';
import TagDropContainer from '-/components/TagDropContainer';
-import {
- actions as AppActions,
- AppDispatch,
- getLastSelectedEntryPath,
- getSelectedEntries
-} from '-/reducers/app';
+import { actions as AppActions, AppDispatch } from '-/reducers/app';
import CellContent from '-/perspectives/grid-perspective/components/CellContent';
import MainToolbar from '-/perspectives/grid-perspective/components/MainToolbar';
import SortingMenu from '-/perspectives/grid-perspective/components/SortingMenu';
@@ -53,6 +48,8 @@ import { openURLExternally } from '-/services/utils-io';
import { useSortedDirContext } from '-/perspectives/grid-perspective/hooks/useSortedDirContext';
import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
+import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
+import { useFsActionsContext } from '-/hooks/useFsActionsContext';
interface Props {
openRenameEntryDialog: () => void;
@@ -81,6 +78,7 @@ function ListPerspective(props: Props) {
currentDirectoryPath,
setDirectoryMeta
} = useDirectoryContentContext();
+ const { openFileNatively } = useFsActionsContext();
const dispatch: AppDispatch = useDispatch();
const {
@@ -91,10 +89,11 @@ function ListPerspective(props: Props) {
setOrderBy
} = useSortedDirContext();
const desktopMode = useSelector(getDesktopMode);
- const selectedEntries: Array<TS.FileSystemEntry> = useSelector(
- getSelectedEntries
- );
- const lastSelectedEntryPath = useSelector(getLastSelectedEntryPath);
+ const {
+ selectedEntries,
+ setSelectedEntries,
+ lastSelectedEntryPath
+ } = useSelectedEntriesContext();
const keyBindings = useSelector(getKeyBindingObject);
//const searchFilter: string = useSelector(getSearchFilter);
/*const editedEntryPaths: Array<TS.EditedEntryPath> = useSelector(
@@ -106,11 +105,7 @@ function ListPerspective(props: Props) {
const selected = showDirectories.current
? entries
: entries.filter(entry => entry.isFile);
- dispatch(AppActions.setSelectedEntries(selected));
- };
-
- const handleOpenFileNatively = (path?: string) => {
- dispatch(AppActions.openFileNatively(path));
+ setSelectedEntries(selected);
};
const isLocal =
@@ -224,7 +219,7 @@ function ListPerspective(props: Props) {
);
// 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);
+ const [ignored, forceUpdate] = useReducer(x => x + 1, 0, undefined);
const firstRender = useFirstRender();
useEffect(() => {
@@ -544,7 +539,7 @@ function ListPerspective(props: Props) {
openEntry();
},
openFileExternally: () => {
- handleOpenFileNatively();
+ openFileNatively();
}
};
@@ -605,7 +600,6 @@ function ListPerspective(props: Props) {
entrySize={entrySize.current}
isLast={isLast}
thumbnailMode={thumbnailMode.current}
- selectedEntries={selectedEntries}
selectEntry={selectEntry}
deselectEntry={deselectEntry}
handleTagMenu={handleTagMenu}
@@ -678,7 +672,6 @@ function ListPerspective(props: Props) {
selectedEntries={selectedEntries}
setSelectedEntries={handleSetSelectedEntries}
singleClickAction={singleClickAction.current}
- openFileNatively={handleOpenFileNatively}
setFileContextMenuAnchorEl={setFileContextMenuAnchorEl}
setDirContextMenuAnchorEl={setDirContextMenuAnchorEl}
clearSelection={clearSelection}
@@ -688,7 +681,6 @@ function ListPerspective(props: Props) {
<AddRemoveTagsDialog
open={isAddRemoveTagsDialogOpened}
onClose={() => setIsAddRemoveTagsDialogOpened(false)}
- selectedEntries={selectedEntries}
/>
)}
{isAddTagDialogOpened !== undefined && (
@@ -765,11 +757,9 @@ function ListPerspective(props: Props) {
: undefined
}
openAddRemoveTagsDialog={openAddRemoveTagsDialog}
- openFileNatively={handleOpenFileNatively}
selectedFilePath={
lastSelectedEntryPath ? lastSelectedEntryPath : currentDirectoryPath
}
- selectedEntries={selectedEntries}
/>
)}
{/* {Boolean(dirContextMenuAnchorEl) && ( // todo move dialogs from DirectoryMenu */}
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index 5febc1286..322f7d4f7 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -82,8 +82,8 @@ export const types = {
SET_SEARCH_FILTER: 'APP/SET_SEARCH_FILTER',
SET_NEW_VERSION_AVAILABLE: 'APP/SET_NEW_VERSION_AVAILABLE',
SET_CURRENLOCATIONID: 'APP/SET_CURRENLOCATIONID',
- SET_LAST_SELECTED_ENTRY: 'APP/SET_LAST_SELECTED_ENTRY',
- SET_SELECTED_ENTRIES: 'APP/SET_SELECTED_ENTRIES',
+ //SET_LAST_SELECTED_ENTRY: 'APP/SET_LAST_SELECTED_ENTRY',
+ //SET_SELECTED_ENTRIES: 'APP/SET_SELECTED_ENTRIES',
SET_TAG_LIBRARY_CHANGED: 'APP/SET_TAG_LIBRARY_CHANGED',
SET_FILEDRAGGED: 'APP/SET_FILEDRAGGED',
TOGGLE_EDIT_TAG_DIALOG: 'APP/TOGGLE_EDIT_TAG_DIALOG',
@@ -216,7 +216,7 @@ export const initialState = {
createDirectoryDialogOpened: null,
importKanBanDialogOpened: false,
// lastSelectedEntry: null,
- selectedEntries: [],
+ //selectedEntries: [],
tagLibraryChanged: false,
isEntryInFullWidth: false,
//isGeneratingThumbs: false,
@@ -303,7 +303,7 @@ export default (state: any = initialState, action: any) => {
}
return state;
}
- case types.SET_SELECTED_ENTRIES: {
+ /*case types.SET_SELECTED_ENTRIES: {
if (
JSON.stringify(action.selectedEntries) !==
JSON.stringify(state.selectedEntries)
@@ -311,7 +311,7 @@ export default (state: any = initialState, action: any) => {
return { ...state, selectedEntries: action.selectedEntries };
}
return state;
- }
+ }*/
case types.SET_TAG_LIBRARY_CHANGED: {
return { ...state, tagLibraryChanged: !state.tagLibraryChanged };
}
@@ -542,24 +542,24 @@ export default (state: any = initialState, action: any) => {
PlatformIO.getDirSeparator()
).replace(/[/\\]/g, '') ===
state.currentDirectoryPath.replace(/[/\\]/g, '')
- ) {
- const editedEntryPaths: Array<TS.EditedEntryPath> = action.fsEntries.map(
- newEntry => ({
- action: newEntry.isFile ? 'createFile' : 'createDir',
- path: newEntry.path,
- uuid: newEntry.uuid
- })
- );
- return {
- ...state,
- editedEntryPaths,
- currentDirectoryEntries: [
+ ) {*/
+ const editedEntryPaths: Array<TS.EditedEntryPath> = action.fsEntries.map(
+ newEntry => ({
+ action: newEntry.isFile ? 'createFile' : 'createDir',
+ path: newEntry.path,
+ uuid: newEntry.uuid
+ })
+ );
+ return {
+ ...state,
+ editedEntryPaths
+ /*currentDirectoryEntries: [
...state.currentDirectoryEntries,
...action.fsEntries
- ]
- };
- }*/
- return state;
+ ]*/
+ };
+ /*}
+ return state;*/
}
case types.REFLECT_RENAME_ENTRY: {
/*const extractedTags = extractTagsAsObjects(
@@ -968,7 +968,7 @@ export const actions = {
openTagLibraryPanel: () => ({ type: types.OPEN_TAGLIBRARY_PANEL }),
openSearchPanel: () => ({ type: types.OPEN_SEARCH_PANEL }),
openHelpFeedbackPanel: () => ({ type: types.OPEN_HELPFEEDBACK_PANEL }),
- setSelectedEntries: (selectedEntries: Array<TS.FileSystemEntry>) => (
+ /*setSelectedEntries: (selectedEntries: Array<TS.FileSystemEntry>) => (
dispatch: (action) => void
) => {
// const { openedFiles } = getState().app;
@@ -976,11 +976,11 @@ export const actions = {
// if (openedFiles.length === 0 || !openedFiles[0].editMode) {
dispatch(actions.setSelectedEntriesInt(selectedEntries));
// }
- },
- setSelectedEntriesInt: (selectedEntries: Array<TS.FileSystemEntry>) => ({
+ },*/
+ /*setSelectedEntriesInt: (selectedEntries: Array<TS.FileSystemEntry>) => ({
type: types.SET_SELECTED_ENTRIES,
selectedEntries
- }),
+ }),*/
addTag: (tag: any, parentTagGroupUuid: TS.Uuid) => (
dispatch: (action) => void,
getState: () => any
@@ -1014,45 +1014,45 @@ export const actions = {
type: types.REFLECT_CREATE_ENTRY,
newEntry
}),
- reflectCreateEntriesInt: (fsEntries: Array<TS.FileSystemEntry>) => ({
+ reflectCreateEntries: (fsEntries: Array<TS.FileSystemEntry>) => ({
type: types.REFLECT_CREATE_ENTRIES,
fsEntries
}),
- reflectCreateEntries: (fsEntries: Array<TS.FileSystemEntry>) => (
+ /*reflectCreateEntries: (fsEntries: Array<TS.FileSystemEntry>) => (
dispatch: (action) => void
) => {
dispatch(actions.reflectCreateEntriesInt(fsEntries));
dispatch(actions.setSelectedEntries(fsEntries));
- },
+ },*/
reflectCreateEntry: (path: string, isFile: boolean) => (
dispatch: (action) => void
) => {
- dispatch(actions.reflectCreateEntryObj(toFsEntry(path, isFile)));
+ dispatch(actions.reflectCreateEntries([toFsEntry(path, isFile)]));
},
- reflectCreateEntryObj: (newEntry: TS.FileSystemEntry) => (
+ /*reflectCreateEntryObj: (newEntry: TS.FileSystemEntry) => (
dispatch: (action) => void
) => {
dispatch(actions.setSelectedEntries([newEntry]));
dispatch(actions.reflectCreateEntryInt(newEntry));
//GlobalSearch.getInstance().reflectCreateEntry(newEntry);
- },
- reflectRenameEntryInt: (path: string, newPath: string) => ({
+ },*/
+ reflectRenameEntry: (path: string, newPath: string) => ({
type: types.REFLECT_RENAME_ENTRY,
path,
newPath
}),
- reflectRenameEntry: (path: string, newPath: string) => (
+ /*reflectRenameEntry: (path: string, newPath: string) => (
dispatch: (action) => void
) => {
dispatch(actions.reflectRenameEntryInt(path, newPath));
// GlobalSearch.getInstance().reflectRenameEntry(path, newPath);
dispatch(actions.setSelectedEntries([]));
- },
+ },*/
reflectEditedEntryPaths: (editedEntryPaths: Array<TS.EditedEntryPath>) => ({
type: types.REFLECT_EDITED_ENTRY_PATHS,
editedEntryPaths
- }),
- openFileNatively: (selectedFile?: string) => (
+ })
+ /*openFileNatively: (selectedFile: string) => (
dispatch: (action) => void,
getState: () => any
) => {
@@ -1072,7 +1072,7 @@ export const actions = {
const { warningOpeningFilesExternally } = getState().settings;
PlatformIO.openFile(selectedFile, warningOpeningFilesExternally);
}
- }
+ }*/
};
// Selectors
@@ -1094,7 +1094,7 @@ export const getProgress = (state: any) => state.app.progress;
export const isUpdateAvailable = (state: any) => state.app.isUpdateAvailable;
export const isUpdateInProgress = (state: any) => state.app.isUpdateInProgress;
export const isOnline = (state: any) => state.app.isOnline;
-export const getLastSelectedEntry = (state: any) => {
+/*export const getLastSelectedEntry = (state: any) => {
const { selectedEntries } = state.app;
if (selectedEntries && selectedEntries.length > 0) {
return selectedEntries[selectedEntries.length - 1];
@@ -1107,13 +1107,13 @@ export const getLastSelectedEntryPath = (state: any) => {
return selectedEntries[selectedEntries.length - 1].path;
}
return undefined;
-};
+};*/
export const getSelectedTag = (state: any) => state.app.tag;
export const isTagLibraryChanged = (state: any) => state.app.tagLibraryChanged;
-export const getSelectedEntries = (state: any) =>
- state.app.selectedEntries ? state.app.selectedEntries : [];
-export const getSelectedEntriesLength = (state: any) =>
- state.app.selectedEntries ? state.app.selectedEntries.length : 0;
+/*export const getSelectedEntries = (state: any) =>
+ state.app.selectedEntries ? state.app.selectedEntries : [];*/
+/*export const getSelectedEntriesLength = (state: any) =>
+ state.app.selectedEntries ? state.app.selectedEntries.length : 0;*/
export const getExtensions = (state: any) => state.app.extensions;
// export const getDirectoryMeta = (state: any) => state.app.directoryMeta;
// export const isGeneratingThumbs = (state: any) => state.app.isGeneratingThumbs;
diff --git a/app/services/platform-facade.ts b/app/services/platform-facade.ts
index c1d2264b7..130cf5ebf 100644
--- a/app/services/platform-facade.ts
+++ b/app/services/platform-facade.ts
@@ -63,7 +63,7 @@ import {
platformOpenDirectory,
platformShowInFileManager,
platformOpenFile,
- platformResolveFilePath,
+ // platformResolveFilePath,
platformOpenUrl,
platformSelectFileDialog,
platformSelectDirectoryDialog,
@@ -527,8 +527,9 @@ export default class PlatformFacade {
}
};
+ /* @deprecated not work in S3 use getLocationPath instead
static resolveFilePath = (filePath: string): string =>
- platformResolveFilePath(filePath);
+ platformResolveFilePath(filePath);*/
static openUrl = (url: string): void => platformOpenUrl(url);
diff --git a/tests/e2e/fileopener.pw.e2e.js b/tests/e2e/fileopener.pw.e2e.js
index 235f8ffe9..9bd53545c 100644
--- a/tests/e2e/fileopener.pw.e2e.js
+++ b/tests/e2e/fileopener.pw.e2e.js
@@ -148,9 +148,14 @@ test.describe('TST08 - File folder properties', () => {
await setSettings('[data-tid=settingsSetPersistTagsInSidecarFile]', true);
// open fileProperties
- await clickOn(getGridFileSelector(fileName));
+ await openContextEntryMenu(
+ getGridFileSelector(fileName),
+ 'showPropertiesTID'
+ );
+ //await clickOn(getGridFileSelector(fileName));
+
//Toggle Properties
- await clickOn('[data-tid=detailsTabTID]');
+ //await clickOn('[data-tid=detailsTabTID]');
await AddRemovePropertiesTags(['test-tag1', 'test-tag2'], {
add: true,
@@ -222,8 +227,14 @@ test.describe('TST08 - File folder properties', () => {
8000,
'[data-tid=perspectiveGridFileTable]'
);
- await clickOn(getGridFileSelector('sample[' + tagName + '].txt'));
- await clickOn('[data-tid=detailsTabTID]');
+
+ await openContextEntryMenu(
+ getGridFileSelector('sample[' + tagName + '].txt'),
+ 'showPropertiesTID'
+ );
+
+ //await clickOn(getGridFileSelector('sample[' + tagName + '].txt'));
+ //await clickOn('[data-tid=detailsTabTID]');
const propsTags = await getPropertiesTags();
expect(propsTags).toContain(tagName);