Skip to content

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

chore: fixing link extraction

Ilian Sapundshiev50849695a1da
diff --git a/src/renderer/components/LinksTab.tsx b/src/renderer/components/LinksTab.tsx
index 5c17cd6fb..9c82f3f92 100644
--- a/src/renderer/components/LinksTab.tsx
+++ b/src/renderer/components/LinksTab.tsx
@@ -28,7 +28,10 @@ import { TS } from '-/tagspaces.namespace';
import { getURLParameter } from '-/utils/dom';
import { Box, Typography } from '@mui/material';
import { extractLinks } from '@tagspaces/tagspaces-common/misc';
-import { generateSharingLink } from '@tagspaces/tagspaces-common/paths';
+import {
+ cleanRootPath,
+ generateSharingLink,
+} from '@tagspaces/tagspaces-common/paths';
import { useEffect, useReducer, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
@@ -151,21 +154,27 @@ function LinksTab(props: Props) {
const incomingLinkButton = (fsEntry: TS.FileSystemEntry) => {
let buttonTitle = fsEntry.name;
+ const entryLocation = findLocation(fsEntry.locationID);
+ const relativeEntryPath = cleanRootPath(
+ fsEntry.path,
+ entryLocation.path,
+ entryLocation.getDirSeparator(),
+ );
const sharingLink = generateSharingLink(
fsEntry.locationID,
+ relativeEntryPath,
undefined,
- fsEntry.path,
fsEntry.uuid,
);
return (
<>
<TsButton
data-tid={'linkTID' + fsEntry.uuid}
- tooltip={fsEntry.path}
+ tooltip={sharingLink}
onClick={() => openLink(sharingLink)}
variant="text"
startIcon={
- <TooltipTS title={sharingLink}>
+ <TooltipTS title={fsEntry.path}>
<LinkIcon />
</TooltipTS>
}
@@ -184,21 +193,6 @@ function LinksTab(props: Props) {
);
};
- const findInboundButton = (title) => (
- <TsButton
- loading={isIndexing !== undefined}
- data-tid={'generateInboundTID'}
- onClick={() =>
- title === 'reGenerateInbound'
- ? refreshInboundLinks()
- : setInboundLinks()
- }
- startIcon={<ReloadIcon />}
- >
- {t('core:' + title)}
- </TsButton>
- );
-
return (
<>
<Box display="block">
@@ -219,16 +213,23 @@ function LinksTab(props: Props) {
{t('full text search should be enabled for this location')}):
</Typography>
<br />
- {indexExist.current ? (
+ {inboundLinks.current?.length ? (
<>
- {inboundLinks.current?.map((entry) => {
+ {inboundLinks.current.map((entry) => {
return incomingLinkButton(entry);
})}
- {findInboundButton('reGenerateInbound')}
</>
) : (
- findInboundButton('generateInbound')
+ <Typography variant="caption">No incoming links found</Typography>
)}
+ <TsButton
+ loading={isIndexing !== undefined}
+ data-tid={'generateInboundTID'}
+ onClick={refreshInboundLinks}
+ startIcon={<ReloadIcon />}
+ >
+ {t('core:generateInbound')}
+ </TsButton>
</Box>
</>
);
diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.json
index 80a7e56b0..a0986fe84 100644
--- a/src/renderer/locales/en/core.json
+++ b/src/renderer/locales/en/core.json
@@ -911,7 +911,6 @@
"outgoingLinks": "Outgoing Links",
"incomingLinks": "Incoming Links",
"generateInbound": "Find Incoming Links",
- "reGenerateInbound": "Refresh Incoming Links",
"startDownload": "Start download",
"confirmHistoryDeletion": "Do you want to delete the AI-chat history?",
"-": "-"