Skip to content

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

fix Copied folder sharing link do not have entryId

sytolk67072de0b99e
diff --git a/src/renderer/components/menus/DirectoryMenu.tsx b/src/renderer/components/menus/DirectoryMenu.tsx
index deb5ff0fd..4b20748dd 100644
--- a/src/renderer/components/menus/DirectoryMenu.tsx
+++ b/src/renderer/components/menus/DirectoryMenu.tsx
@@ -81,7 +81,7 @@ function DirectoryMenu(props: Props) {
const { openNewFileDialog } = useNewFileDialogContext();
const { currentLocation, readOnlyMode, getLocationPath, findLocation } =
useCurrentLocationContext();
- const { setThumbnailImageChange } = useIOActionsContext();
+ const { setThumbnailImageChange, getMetadataID } = useIOActionsContext();
const { showNotification } = useNotificationContext();
const { openFileUpload } = useFileUploadContext();
const { openCreateDirectoryDialog } = useCreateDirectoryDialogContext();
@@ -129,10 +129,16 @@ function DirectoryMenu(props: Props) {
selectedEntries[0].name,
currentLocation?.getDirSeparator(),
);
- return {
- url: generateSharingLink(locationID, undefined, relativePath),
- name: folderName,
- };
+ return getMetadataID(
+ selectedEntries[0].path,
+ selectedEntries[0].uuid,
+ tmpLoc,
+ ).then((id) => {
+ return {
+ url: generateSharingLink(locationID, undefined, relativePath, id),
+ name: folderName,
+ };
+ });
});
}
diff --git a/src/renderer/components/menus/FileMenu.tsx b/src/renderer/components/menus/FileMenu.tsx
index 89e5ee45f..7ae1face9 100644
--- a/src/renderer/components/menus/FileMenu.tsx
+++ b/src/renderer/components/menus/FileMenu.tsx
@@ -115,6 +115,7 @@ function FileMenu(props: Props) {
duplicateFile,
setFolderBackgroundPromise,
downloadFsEntry,
+ getMetadataID,
} = useIOActionsContext();
const { openEntry } = useOpenedEntryContext();
const { openDirectory, currentLocationPath, getAllPropertiesPromise } =
@@ -136,10 +137,16 @@ function FileMenu(props: Props) {
}
}, [currentLocation, selectedFilePath]);
- function generateFileLink() {
+ function generateFileLink(): Promise<string> {
const entryPath = selectedEntries[0].path;
const relativePath = getRelativeEntryPath(currentLocationPath, entryPath);
- return generateSharingLink(currentLocation.uuid, relativePath);
+ return getMetadataID(
+ selectedEntries[0].path,
+ selectedEntries[0].uuid,
+ currentLocation,
+ ).then((id) =>
+ generateSharingLink(currentLocation.uuid, relativePath, undefined, id),
+ );
}
function showProperties() {
@@ -152,25 +159,26 @@ function FileMenu(props: Props) {
function copySharingLink() {
onClose();
if (selectedEntries && selectedEntries.length === 1) {
- const sharingLink = generateFileLink();
- const entryTitle = extractTitle(
- selectedEntries[0].name,
- !selectedEntries[0].isFile,
- currentLocation?.getDirSeparator(),
- );
+ generateFileLink().then((sharingLink) => {
+ const entryTitle = extractTitle(
+ selectedEntries[0].name,
+ !selectedEntries[0].isFile,
+ currentLocation?.getDirSeparator(),
+ );
- const clibboardItem = generateClipboardLink(sharingLink, entryTitle);
-
- navigator.clipboard
- .write(clibboardItem)
- .then(() => {
- showNotification(t('core:sharingLinkCopied'));
- return true;
- })
- .catch((e) => {
- console.log('Error copying to clipboard ' + e);
- showNotification(t('core:sharingLinkFailed'));
- });
+ const clibboardItem = generateClipboardLink(sharingLink, entryTitle);
+
+ navigator.clipboard
+ .write(clibboardItem)
+ .then(() => {
+ showNotification(t('core:sharingLinkCopied'));
+ return true;
+ })
+ .catch((e) => {
+ console.log('Error copying to clipboard ' + e);
+ showNotification(t('core:sharingLinkFailed'));
+ });
+ });
}
}
@@ -288,10 +296,11 @@ function FileMenu(props: Props) {
function openInNewWindow() {
onClose();
if (selectedEntries && selectedEntries.length === 1) {
- const sharingLink = generateFileLink();
- const newInstanceLink =
- window.location.href.split('?')[0] + '?' + sharingLink.split('?')[1];
- createNewInstance(newInstanceLink);
+ generateFileLink().then((sharingLink) => {
+ const newInstanceLink =
+ window.location.href.split('?')[0] + '?' + sharingLink.split('?')[1];
+ createNewInstance(newInstanceLink);
+ });
}
}