Skip to content

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

fix native dnd (#2168)

Stanimir599e08d2298a
diff --git a/src/main/preload.ts b/src/main/preload.ts
index 45e6a18d4..239d8bb0c 100644
--- a/src/main/preload.ts
+++ b/src/main/preload.ts
@@ -1,6 +1,11 @@
// Disable no-unused-vars, broken for spread args
/* eslint no-unused-vars: off */
-import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';
+import {
+ contextBridge,
+ ipcRenderer,
+ IpcRendererEvent,
+ webUtils,
+} from 'electron';
export type Channels =
| 'isWorkerAvailable'
@@ -89,6 +94,9 @@ const electronHandler = {
removeAllListeners(channel: string) {
ipcRenderer.removeAllListeners(channel);
},
+ getPathForFile(file: File) {
+ return webUtils.getPathForFile(file);
+ },
},
};
diff --git a/src/renderer/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider.tsx
index 1025998bc..36da84dd2 100644
--- a/src/renderer/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider.tsx
+++ b/src/renderer/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider.tsx
@@ -64,6 +64,15 @@ export const MoveOrCopyFilesDialogContextProvider = ({
targetDirectory?: string,
targetLocationID?: string,
) {
+ if (!selectedFiles || selectedFiles.length === 0) {
+ return;
+ }
+ selectedFiles = selectedFiles.map((file) => {
+ if (!file.path) {
+ file.path = window.electronIO.ipcRenderer.getPathForFile(file);
+ }
+ return file;
+ });
open.current = true;
targetDir.current = targetDirectory;
targetLocationId.current = targetLocationID;
diff --git a/src/renderer/hooks/IOActionsContextProvider.tsx b/src/renderer/hooks/IOActionsContextProvider.tsx
index d6edf6e2d..0d7b30b8b 100644
--- a/src/renderer/hooks/IOActionsContextProvider.tsx
+++ b/src/renderer/hooks/IOActionsContextProvider.tsx
@@ -950,7 +950,10 @@ export const IOActionsContextProvider = ({
if (thumbPath) {
const tmbPath =
await currentLocation.getURLforPathInt(thumbPath);
- fsEntry.meta.thumbPath = tmbPath;
+ fsEntry.meta = {
+ ...fsEntry.meta,
+ thumbPath: tmbPath,
+ };
}
fsEntries.push(fsEntry);
showNotification(