Skip to content

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

chore: merging the two movecopyfiles dialogs into one

Ilian Sapundshieva8876ae0da39
diff --git a/src/renderer/components/TargetFileBox.tsx b/src/renderer/components/TargetFileBox.tsx
index 5ec601432..c6a7de8c8 100644
--- a/src/renderer/components/TargetFileBox.tsx
+++ b/src/renderer/components/TargetFileBox.tsx
@@ -18,7 +18,7 @@
import AppConfig from '-/AppConfig';
import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';
-import { useMoveOrCopyFilesDialogContext } from '-/components/dialogs/hooks/useMoveOrCopyFilesDialogContext';
+import { useMenuContext } from '-/components/dialogs/hooks/useMenuContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';
@@ -28,6 +28,8 @@ import { useNotificationContext } from '-/hooks/useNotificationContext';
import { actions as AppActions, AppDispatch } from '-/reducers/app';
import { TS } from '-/tagspaces.namespace';
import { alpha, useTheme } from '@mui/material/styles';
+import { extractFileExtension } from '@tagspaces/tagspaces-common/paths';
+import { getUuid } from '@tagspaces/tagspaces-common/utils-io';
import { Identifier } from 'dnd-core';
import React, { ReactNode } from 'react';
import { DropTargetMonitor, useDrop } from 'react-dnd';
@@ -60,7 +62,7 @@ function TargetFileBox(props: Props) {
const { showNotification } = useNotificationContext();
const { setReflectMetaActions } = useEditedEntryMetaContext();
const { currentDirectoryPath } = useDirectoryContentContext();
- const { openMoveOrCopyFilesDialog } = useMoveOrCopyFilesDialogContext();
+ const { openMoveCopyFilesDialog } = useMenuContext();
//const ref = useRef<HTMLDivElement>(null);
const { children, accepts, directoryPath, style, locationId } = props;
const dirPath = directoryPath ? directoryPath : currentDirectoryPath;
@@ -129,6 +131,38 @@ function TargetFileBox(props: Props) {
return Promise.reject(new Error('on files'));
};
+ function openDropChoiceDialog(
+ files: File[],
+ targetDirPath: string,
+ targetLocationUuid: string,
+ ) {
+ const isDirsPromise: Promise<boolean[]> = AppConfig.isElectron
+ ? Promise.all(
+ files.map((file) =>
+ window.electronIO.ipcRenderer.invoke('isDirectory', file.path),
+ ),
+ )
+ : Promise.resolve(files.map(() => true));
+ return isDirsPromise.then((isDirsArray) => {
+ const entries: TS.FileSystemEntry[] = files
+ .map((file, index) => ({
+ uuid: getUuid(),
+ name: file.name,
+ path: file.path,
+ isFile: !isDirsArray[index],
+ extension: extractFileExtension(file.path),
+ size: file.size,
+ cdt: (file as any).cdt,
+ lmdt: file.lastModified,
+ }))
+ .filter((entry) => entry.isFile);
+ if (entries.length === 0) {
+ return;
+ }
+ openMoveCopyFilesDialog(entries, targetDirPath, targetLocationUuid, true);
+ });
+ }
+
const [collectedProps, drop] = useDrop<DragItem, unknown, DragProps>(
() => ({
accept: accepts,
@@ -153,11 +187,7 @@ function TargetFileBox(props: Props) {
!targetLocation.haveObjectStoreSupport() &&
!targetLocation.haveWebDavSupport()
) {
- return openMoveOrCopyFilesDialog(
- files,
- dirPath,
- targetLocation.uuid,
- );
+ return openDropChoiceDialog(files, dirPath, targetLocation.uuid);
} else {
return handleCopyFiles(files, targetLocation);
}
diff --git a/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx b/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx
index 4181443c2..9b68a1ac5 100644
--- a/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx
+++ b/src/renderer/components/dialogs/MoveCopyFilesDialog.tsx
@@ -9,10 +9,14 @@ import { useEntryExistDialogContext } from '-/components/dialogs/hooks/useEntryE
import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
+import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
import { actions as AppActions, AppDispatch } from '-/reducers/app';
-import { getDirProperties } from '-/services/utils-io';
+import {
+ executePromisesInBatches,
+ getDirProperties,
+} from '-/services/utils-io';
import { TS } from '-/tagspaces.namespace';
import Box from '@mui/material/Box';
import Dialog from '@mui/material/Dialog';
@@ -25,6 +29,7 @@ import Typography from '@mui/material/Typography';
import { useTheme } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';
import { formatBytes } from '@tagspaces/tagspaces-common/misc';
+import { extractFileName, joinPaths } from '@tagspaces/tagspaces-common/paths';
import { useEffect, useReducer, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useDispatch } from 'react-redux';
@@ -36,18 +41,29 @@ interface Props {
entries: TS.FileSystemEntry[];
targetDir?: string;
targetLocationId?: string;
+ // when true the target-directory picker is hidden and post-op
+ // thumb-generation + sendDirMessage are triggered (drag-drop import path)
+ skipTargetPicker?: boolean;
}
function MoveCopyFilesDialog(props: Props) {
const { t } = useTranslation();
const dispatch: AppDispatch = useDispatch();
- const { open, entries, onClose, targetDir, targetLocationId } = props;
+ const {
+ open,
+ entries,
+ onClose,
+ targetDir,
+ targetLocationId,
+ skipTargetPicker,
+ } = props;
const { findLocation } = useCurrentLocationContext();
- const { currentDirectoryPath } = useDirectoryContentContext();
+ const { currentDirectoryPath, sendDirMessage } = useDirectoryContentContext();
const { handleEntryExist, openEntryExistDialog } =
useEntryExistDialogContext();
const { copyFiles, copyDirs, moveFiles, moveDirs } = useIOActionsContext();
const { openFileUploadDialog } = useFileUploadDialogContext();
+ const { setReflectMetaActions } = useEditedEntryMetaContext();
const { selectedEntries } = useSelectedEntriesContext();
const currentEntries = entries || selectedEntries;
@@ -107,17 +123,47 @@ function MoveCopyFilesDialog(props: Props) {
});
}
+ function generateThumbsForTransferred(sourceFilePaths: string[]) {
+ if (!targetLocation) {
+ return;
+ }
+ const sep = targetLocation.getDirSeparator();
+ const promises: Promise<TS.EditMetaAction>[] = sourceFilePaths.map(
+ (filePath) =>
+ targetLocation
+ .getPropertiesPromise(
+ joinPaths(sep, targetPath, extractFileName(filePath, sep)),
+ )
+ .then((entry) => ({ action: 'thumbGenerate', entry })),
+ );
+ executePromisesInBatches(promises).then((actions) => {
+ setReflectMetaActions(...actions);
+ });
+ }
+
function handleCopy() {
- dispatch(AppActions.resetProgress());
- openFileUploadDialog(targetDir, 'copyEntriesTitle'); //selectedFiles.length > 0);
+ if (!skipTargetPicker) {
+ dispatch(AppActions.resetProgress());
+ openFileUploadDialog(targetDir, 'copyEntriesTitle');
+ }
if (selectedFiles.length > 0) {
//todo use uploadFilesAPI && transferMeta = true
- copyFiles(
- selectedFiles,
+ const filePaths = selectedFiles;
+ const onProgress = skipTargetPicker ? undefined : onUploadProgress;
+ const copyPromise = copyFiles(
+ filePaths,
targetPath,
targetLocation.uuid,
- onUploadProgress,
+ onProgress,
);
+ if (skipTargetPicker) {
+ Promise.resolve(copyPromise).then((success) => {
+ if (success) {
+ generateThumbsForTransferred(filePaths);
+ }
+ return true;
+ });
+ }
setTargetPath('');
}
if (selectedDirs.length > 0) {
@@ -125,7 +171,7 @@ function MoveCopyFilesDialog(props: Props) {
getEntriesCount(selectedDirs),
targetPath,
targetLocation.uuid,
- onUploadProgress,
+ skipTargetPicker ? undefined : onUploadProgress,
);
}
onClose(true);
@@ -137,24 +183,36 @@ function MoveCopyFilesDialog(props: Props) {
function handleMove() {
if (selectedFiles.length > 0) {
- moveFiles(
- selectedFiles,
+ const filePaths = selectedFiles;
+ const movePromise = moveFiles(
+ filePaths,
targetPath,
targetLocation.uuid,
- onUploadProgress,
+ skipTargetPicker ? undefined : onUploadProgress,
true,
true,
);
+ if (skipTargetPicker) {
+ Promise.resolve(movePromise).then((success) => {
+ if (success) {
+ sendDirMessage('moveFiles', filePaths);
+ generateThumbsForTransferred(filePaths);
+ }
+ return true;
+ });
+ }
setTargetPath('');
}
if (selectedDirs.length > 0) {
- dispatch(AppActions.resetProgress());
- openFileUploadDialog(undefined, 'moveEntriesTitle');
+ if (!skipTargetPicker) {
+ dispatch(AppActions.resetProgress());
+ openFileUploadDialog(undefined, 'moveEntriesTitle');
+ }
moveDirs(
getEntriesCount(selectedDirs),
targetPath,
targetLocation.uuid,
- onUploadProgress,
+ skipTargetPicker ? undefined : onUploadProgress,
);
}
onClose(true);
@@ -227,11 +285,13 @@ function MoveCopyFilesDialog(props: Props) {
</ListItem>
))}
</List>
- <DirectoryListView
- setTargetDir={setTargetPath}
- targetPath={targetPath}
- targetLocationID={targetLocation?.uuid}
- />
+ {!skipTargetPicker && (
+ <DirectoryListView
+ setTargetDir={setTargetPath}
+ targetPath={targetPath}
+ targetLocationID={targetLocation?.uuid}
+ />
+ )}
<Box sx={{ marginTop: '10px' }}>
{targetPath ? (
<Typography variant="subtitle2">
@@ -253,8 +313,7 @@ function MoveCopyFilesDialog(props: Props) {
data-tid="confirmMoveFiles"
disabled={
!targetPath ||
- // AppConfig.isAndroid ||
- targetPath === currentDirectoryPath
+ (!skipTargetPicker && targetPath === currentDirectoryPath)
}
onClick={() => copyMove(false)}
variant="contained"
@@ -265,7 +324,10 @@ function MoveCopyFilesDialog(props: Props) {
<TsButton
onClick={() => copyMove(true)}
data-tid="confirmCopyFiles"
- disabled={!targetPath || targetPath === currentDirectoryPath}
+ disabled={
+ !targetPath ||
+ (!skipTargetPicker && targetPath === currentDirectoryPath)
+ }
variant="contained"
>
{t('core:copyEntriesButton')}
diff --git a/src/renderer/components/dialogs/MoveOrCopyFilesDialog.tsx b/src/renderer/components/dialogs/MoveOrCopyFilesDialog.tsx
deleted file mode 100644
index bdb781031..000000000
--- a/src/renderer/components/dialogs/MoveOrCopyFilesDialog.tsx
+++ /dev/null
@@ -1,214 +0,0 @@
-/**
- * TagSpaces - universal file and folder organizer
- * Copyright (C) 2017-present TagSpaces GmbH
- *
- * 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/>.
- *
- */
-
-/**
- * Used for the import functionality with drag and drop from the
- * file manager or desktop of the operating system
- */
-
-import DraggablePaper from '-/components/DraggablePaper';
-import TsButton from '-/components/TsButton';
-import TsDialogActions from '-/components/dialogs/components/TsDialogActions';
-import TsDialogTitle from '-/components/dialogs/components/TsDialogTitle';
-import { useEntryExistDialogContext } from '-/components/dialogs/hooks/useEntryExistDialogContext';
-import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
-import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
-import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';
-import { useIOActionsContext } from '-/hooks/useIOActionsContext';
-import { executePromisesInBatches } from '-/services/utils-io';
-import { TS } from '-/tagspaces.namespace';
-import FileIcon from '@mui/icons-material/InsertDriveFileOutlined';
-import Dialog from '@mui/material/Dialog';
-import DialogContent from '@mui/material/DialogContent';
-import List from '@mui/material/List';
-import ListItem from '@mui/material/ListItem';
-import ListItemIcon from '@mui/material/ListItemIcon';
-import Paper from '@mui/material/Paper';
-import Typography from '@mui/material/Typography';
-import { useTheme } from '@mui/material/styles';
-import useMediaQuery from '@mui/material/useMediaQuery';
-import { extractFileName, joinPaths } from '@tagspaces/tagspaces-common/paths';
-import { useTranslation } from 'react-i18next';
-
-interface Props {
- open: boolean;
- onClose: (clearSelection?: boolean) => void;
- selectedFiles: Array<TS.FileSystemEntry>;
- targetDir?: string;
- targetLocationId?: string;
-}
-
-function MoveOrCopyFilesDialog(props: Props) {
- const { open, onClose, selectedFiles, targetLocationId } = props;
- const { t } = useTranslation();
-
- const theme = useTheme();
-
- const { handleEntryExist } = useEntryExistDialogContext();
- const { setReflectMetaActions } = useEditedEntryMetaContext();
- const { findLocation } = useCurrentLocationContext();
- const { moveFiles, copyFiles } = useIOActionsContext();
- const { currentDirectoryPath, sendDirMessage } = useDirectoryContentContext();
- const smallScreen = useMediaQuery(theme.breakpoints.down('md'));
- const targetDir = props.targetDir ? props.targetDir : currentDirectoryPath;
- const targetLocation = findLocation(targetLocationId);
-
- function generateThumbs(filePaths: string[]) {
- const promises: Promise<TS.EditMetaAction>[] = filePaths.map((filePath) =>
- targetLocation.getPropertiesPromise(filePath).then((entry) => ({
- action: 'thumbGenerate',
- entry: entry,
- })),
- );
- executePromisesInBatches(promises).then((actions) => {
- setReflectMetaActions(...actions);
- });
- }
-
- function handleMove(filePaths: string[]) {
- moveFiles(
- filePaths,
- targetDir,
- targetLocation.uuid,
- undefined,
- true,
- true,
- ).then((success) => {
- if (success) {
- sendDirMessage('moveFiles', filePaths);
- generateThumbs(
- filePaths.map((targetPath) =>
- joinPaths(
- targetLocation?.getDirSeparator(),
- targetDir,
- extractFileName(targetPath, targetLocation?.getDirSeparator()),
- ),
- ),
- );
- }
- return true;
- });
- }
-
- function handleCopy(filePaths: string[]) {
- copyFiles(filePaths, targetDir, targetLocation.uuid).then((success) => {
- if (success) {
- generateThumbs(
- filePaths.map((targetPath) =>
- joinPaths(
- targetLocation?.getDirSeparator(),
- targetDir,
- extractFileName(targetPath, targetLocation?.getDirSeparator()),
- ),
- ),
- );
- }
- return true;
- });
- }
-
- return (
- <Dialog
- open={open && selectedFiles && selectedFiles.length > 0}
- onClose={onClose}
- keepMounted
- scroll="paper"
- aria-labelledby="draggable-dialog-title"
- PaperComponent={smallScreen ? Paper : DraggablePaper}
- fullScreen={smallScreen}
- >
- <TsDialogTitle
- dialogTitle={t('core:copyMoveEntriesTitle')}
- closeButtonTestId="closeMoveOrCopyTID"
- onClose={onClose}
- />
- <DialogContent
- sx={{
- overflowX: 'hidden',
- overflowY: 'auto',
- }}
- >
- <Typography variant="subtitle2">
- {t('core:moveCopyToPath') + ': ' + targetDir}
- </Typography>
- <Typography variant="subtitle2">{t('selectedFiles')}</Typography>
- <List dense sx={{ width: '550px', marginLeft: '-15px' }}>
- {selectedFiles &&
- selectedFiles.length > 0 &&
- selectedFiles.map((file) => (
- <ListItem title={file.path} key={file.path}>
- <ListItemIcon>
- <FileIcon />
- </ListItemIcon>
- <Typography variant="inherit" noWrap>
- {file.name}
- </Typography>
- </ListItem>
- ))}
- </List>
- </DialogContent>
- <TsDialogActions>
- <TsButton data-tid="closeMoveOrCopyDialog" onClick={() => onClose()}>
- {t('core:cancel')}
- </TsButton>
- <TsButton
- onClick={() => {
- if (selectedFiles) {
- const confirmOverride = () => {
- handleMove(selectedFiles.map((file) => file.path));
- };
- handleEntryExist(
- selectedFiles,
- targetDir,
- targetLocationId,
- confirmOverride,
- );
- }
- onClose();
- }}
- data-tid="confirmMoveFilesTID"
- variant="contained"
- >
- {t('core:moveEntriesButton')}
- </TsButton>
- <TsButton
- onClick={() => {
- if (selectedFiles) {
- const confirmOverride = () => {
- handleCopy(selectedFiles.map((file) => file.path));
- };
- handleEntryExist(
- selectedFiles,
- targetDir,
- targetLocationId,
- confirmOverride,
- );
- }
- onClose();
- }}
- data-tid="confirmCopyFilesTID"
- variant="contained"
- >
- {t('core:copyEntriesButton')}
- </TsButton>
- </TsDialogActions>
- </Dialog>
- );
-}
-
-export default MoveOrCopyFilesDialog;
diff --git a/src/renderer/components/dialogs/hooks/MenuContextProvider.tsx b/src/renderer/components/dialogs/hooks/MenuContextProvider.tsx
index c1fcb2c09..b2a8dce02 100644
--- a/src/renderer/components/dialogs/hooks/MenuContextProvider.tsx
+++ b/src/renderer/components/dialogs/hooks/MenuContextProvider.tsx
@@ -56,6 +56,7 @@ type MenuContextData = {
entries: TS.FileSystemEntry[],
targetDirectory?: string,
targetLocationId?: string,
+ skipTargetPicker?: boolean,
) => void;
closeMoveCopyFilesDialog: () => void;
openAddRemoveTagsDialog: (entries: TS.FileSystemEntry[]) => void;
@@ -119,6 +120,7 @@ export const MenuContextProvider = ({ children }: MenuContextProviderProps) => {
const currentEntries = useRef<TS.FileSystemEntry[]>(undefined);
const targetDirectory = useRef<string>(undefined);
const targetLocationId = useRef<string>(undefined);
+ const skipTargetPickerRef = useRef<boolean>(false);
const openRenameEntry = useRef<boolean>(false);
const openMoveCopyFiles = useRef<boolean>(false);
const openAddRemoveTags = useRef<boolean>(false);
@@ -230,11 +232,13 @@ export const MenuContextProvider = ({ children }: MenuContextProviderProps) => {
entries: TS.FileSystemEntry[],
tDirectory?: string,
tLocationId?: string,
+ skipTargetPicker?: boolean,
) => {
openMoveCopyFiles.current = true;
currentEntries.current = entries;
targetDirectory.current = tDirectory;
targetLocationId.current = tLocationId;
+ skipTargetPickerRef.current = !!skipTargetPicker;
forceUpdate();
},
[],
@@ -337,6 +341,7 @@ export const MenuContextProvider = ({ children }: MenuContextProviderProps) => {
entries={currentEntries.current}
targetDir={targetDirectory.current}
targetLocationId={targetLocationId.current}
+ skipTargetPicker={skipTargetPickerRef.current}
/>
<AddRemoveTagsDialogAsync
open={openAddRemoveTags.current}
diff --git a/src/renderer/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider.tsx
deleted file mode 100644
index 434425bb8..000000000
--- a/src/renderer/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider.tsx
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * TagSpaces - universal file and folder organizer
- * Copyright (C) 2017-present TagSpaces GmbH
- *
- * 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, useMemo, useReducer, useRef } from 'react';
-import { extractFileExtension } from '@tagspaces/tagspaces-common/paths';
-import { getUuid } from '@tagspaces/tagspaces-common/utils-io';
-import LoadingLazy from '-/components/LoadingLazy';
-import { TS } from '-/tagspaces.namespace';
-import AppConfig from '-/AppConfig';
-
-type MoveOrCopyFilesDialogContextData = {
- openMoveOrCopyFilesDialog: (
- files: File[] | TS.FileSystemEntry[],
- targetDirectory?: string,
- targetLocationId?: string,
- ) => void;
- closeMoveOrCopyFilesDialog: () => void;
-};
-
-export const MoveOrCopyFilesDialogContext =
- createContext<MoveOrCopyFilesDialogContextData>({
- openMoveOrCopyFilesDialog: undefined,
- closeMoveOrCopyFilesDialog: undefined,
- });
-
-export type MoveOrCopyFilesDialogContextProviderProps = {
- children: React.ReactNode;
-};
-
-const MoveOrCopyFilesDialog = React.lazy(
- () =>
- import(
- /* webpackChunkName: "MoveOrCopyFilesDialog" */ '../MoveOrCopyFilesDialog'
- ),
-);
-
-export const MoveOrCopyFilesDialogContextProvider = ({
- children,
-}: MoveOrCopyFilesDialogContextProviderProps) => {
- const open = useRef<boolean>(false);
- const files = useRef<TS.FileSystemEntry[]>(undefined);
- const targetDir = useRef<string>(undefined);
- const targetLocationId = useRef<string>(undefined);
-
- const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
-
- function isFileArray(value: unknown): value is File[] {
- return Array.isArray(value) && value.every((item) => item instanceof File);
- }
-
- function openDialog(
- selectedFiles: File[] | TS.FileSystemEntry[],
- targetDirectory?: string,
- targetLocationID?: string,
- ) {
- if (!selectedFiles || selectedFiles.length === 0) {
- return;
- }
- open.current = true;
- targetDir.current = targetDirectory;
- targetLocationId.current = targetLocationID;
- if (isFileArray(selectedFiles)) {
- isDirs(selectedFiles).then((isDirsArray) => {
- files.current = selectedFiles.map((file, index) => ({
- uuid: getUuid(),
- name: file.name,
- path: file.path,
- isFile: !isDirsArray[index],
- extension: extractFileExtension(file.path),
- size: file.size,
- cdt: (file as any).cdt,
- lmdt: file.lastModified,
- }));
- forceUpdate();
- });
- } else {
- files.current = selectedFiles;
- }
- forceUpdate();
- }
-
- function isDirs(files: Array<File>): Promise<boolean[]> {
- if (AppConfig.isElectron) {
- const filesPromises = files.map((file) =>
- window.electronIO.ipcRenderer.invoke('isDirectory', file.path),
- );
- return Promise.all(filesPromises);
- }
- return Promise.resolve(files.map(() => true));
- }
-
- function closeDialog() {
- open.current = false;
- forceUpdate();
- }
-
- function MoveOrCopyFilesDialogAsync(props) {
- return (
- <React.Suspense fallback={<LoadingLazy />}>
- <MoveOrCopyFilesDialog {...props} />
- </React.Suspense>
- );
- }
-
- const context = useMemo(() => {
- return {
- openMoveOrCopyFilesDialog: openDialog,
- closeMoveOrCopyFilesDialog: closeDialog,
- };
- }, []);
-
- return (
- <MoveOrCopyFilesDialogContext.Provider value={context}>
- <MoveOrCopyFilesDialogAsync
- open={open.current}
- onClose={closeDialog}
- selectedFiles={files.current?.filter((file) => file.isFile)} // todo enable for dir
- targetDir={targetDir.current}
- targetLocationId={targetLocationId.current}
- />
- {children}
- </MoveOrCopyFilesDialogContext.Provider>
- );
-};
diff --git a/src/renderer/components/dialogs/hooks/useMoveOrCopyFilesDialogContext.tsx b/src/renderer/components/dialogs/hooks/useMoveOrCopyFilesDialogContext.tsx
deleted file mode 100644
index cbaf26678..000000000
--- a/src/renderer/components/dialogs/hooks/useMoveOrCopyFilesDialogContext.tsx
+++ /dev/null
@@ -1,6 +0,0 @@
-import { useContext } from 'react';
-
-import { MoveOrCopyFilesDialogContext } from '-/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider';
-
-export const useMoveOrCopyFilesDialogContext = () =>
- useContext(MoveOrCopyFilesDialogContext);
diff --git a/src/renderer/containers/DialogsRoot.tsx b/src/renderer/containers/DialogsRoot.tsx
index ecde6ae6e..d2e1cd9ce 100644
--- a/src/renderer/containers/DialogsRoot.tsx
+++ b/src/renderer/containers/DialogsRoot.tsx
@@ -28,7 +28,6 @@ import { KeyboardDialogContextProvider } from '-/components/dialogs/hooks/Keyboa
import { LicenseDialogContextProvider } from '-/components/dialogs/hooks/LicenseDialogContextProvider';
import { LinkDialogContextProvider } from '-/components/dialogs/hooks/LinkDialogContextProvider';
import { MenuContextProvider } from '-/components/dialogs/hooks/MenuContextProvider';
-import { MoveOrCopyFilesDialogContextProvider } from '-/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider';
import { NewAudioDialogContextProvider } from '-/components/dialogs/hooks/NewAudioDialogContextProvider';
import { NewFileDialogContextProvider } from '-/components/dialogs/hooks/NewFileDialogContextProvider';
import { OnboardingDialogContextProvider } from '-/components/dialogs/hooks/OnboardingDialogContextProvider';
@@ -49,7 +48,6 @@ const providers = [
EntryExistDialogContextProvider,
DeleteMultipleEntriesDialogContextProvider,
CreateEditLocationDialogContextProvider,
- MoveOrCopyFilesDialogContextProvider,
CreateDirectoryDialogContextProvider,
ProgressDialogContextProvider,
// PerspectiveOnboardingContextProvider must wrap SettingsDialogContextProvider