Skip to content

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

fix upload meta on upload files with DnD

Stanimiraa790cf4d97e
diff --git a/src/renderer/components/FileUploadContainer.tsx b/src/renderer/components/FileUploadContainer.tsx
index 04d25ab00..e1b9c6f52 100644
--- a/src/renderer/components/FileUploadContainer.tsx
+++ b/src/renderer/components/FileUploadContainer.tsx
@@ -39,6 +39,7 @@ interface Props {
export interface FileUploadContainerRef {
onFileUpload: (directoryPath: string) => void;
onMetaUpload: () => void;
+ setMetaUpload: (mUpload: () => void) => void;
}
const FileUploadContainer = forwardRef(
@@ -62,6 +63,9 @@ const FileUploadContainer = forwardRef(
metaUpload.current();
}
},
+ setMetaUpload(mUpload: () => void) {
+ metaUpload.current = mUpload;
+ },
onFileUpload(dirPath: string) {
directoryPath.current = dirPath;
/* if (AppConfig.isCordovaAndroid) {
diff --git a/src/renderer/components/TargetFileBox.tsx b/src/renderer/components/TargetFileBox.tsx
index 23606d7df..fb2810167 100644
--- a/src/renderer/components/TargetFileBox.tsx
+++ b/src/renderer/components/TargetFileBox.tsx
@@ -32,6 +32,7 @@ import { useIOActionsContext } from '-/hooks/useIOActionsContext';
import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';
import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUploadDialogContext';
import { useMoveOrCopyFilesDialogContext } from '-/components/dialogs/hooks/useMoveOrCopyFilesDialogContext';
+import { useFileUploadContext } from '-/hooks/useFileUploadContext';
type DragItem = { files: File[]; items: DataTransferItemList };
type DragProps = {
@@ -54,7 +55,8 @@ function TargetFileBox(props: Props) {
const { openFileUploadDialog } = useFileUploadDialogContext();
const { currentLocation, findLocalLocation, findLocation } =
useCurrentLocationContext();
- const { uploadFilesAPI } = useIOActionsContext();
+ const { setMetaUpload } = useFileUploadContext();
+ const { uploadFilesAPI, uploadMeta } = useIOActionsContext();
const { showNotification } = useNotificationContext();
const { setReflectMetaActions } = useEditedEntryMetaContext();
const { currentDirectoryPath } = useDirectoryContentContext();
@@ -100,6 +102,16 @@ function TargetFileBox(props: Props) {
sourceLocationId,
)
.then((fsEntries: Array<TS.FileSystemEntry>) => {
+ setMetaUpload(() =>
+ uploadMeta(
+ files.map((f) => f.path),
+ dirPath,
+ onUploadProgress,
+ false,
+ undefined,
+ sourceLocationId,
+ ),
+ );
const actions: TS.EditMetaAction[] = fsEntries.map((entry) => ({
action: 'thumbGenerate',
entry: entry,
diff --git a/src/renderer/hooks/FileUploadContextProvider.tsx b/src/renderer/hooks/FileUploadContextProvider.tsx
index 73fb99be2..7ebc01d2a 100644
--- a/src/renderer/hooks/FileUploadContextProvider.tsx
+++ b/src/renderer/hooks/FileUploadContextProvider.tsx
@@ -24,11 +24,13 @@ import FileUploadContainer, {
type FileUploadContextData = {
openFileUpload: (dPath: string) => void;
uploadMeta: () => void;
+ setMetaUpload: (mUpload: () => void) => void;
};
export const FileUploadContext = createContext<FileUploadContextData>({
openFileUpload: undefined,
uploadMeta: undefined,
+ setMetaUpload: undefined,
});
export type FileUploadContextProviderProps = {
@@ -48,10 +50,15 @@ export const FileUploadContextProvider = ({
fileUploadContainerRef.current?.onMetaUpload();
}
+ function setMetaUpload(mUpload: () => void) {
+ fileUploadContainerRef.current?.setMetaUpload(mUpload);
+ }
+
const context = useMemo(() => {
return {
openFileUpload: openFileUpload,
uploadMeta: uploadMeta,
+ setMetaUpload: setMetaUpload,
};
}, []);