TagSpaces is an offline, open source, document manager with tagging support
fix links
sytolkc3417e3f5a82
diff --git a/src/renderer/components/LinksTab.tsx b/src/renderer/components/LinksTab.tsxindex 61dd35e4d..173ee7575 100644--- a/src/renderer/components/LinksTab.tsx+++ b/src/renderer/components/LinksTab.tsx@@ -20,7 +20,6 @@ import { LinkIcon } from '-/components/CommonIcons';import TsButton from '-/components/TsButton';import { TabNames } from '-/hooks/EntryPropsTabsContextProvider';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';-import { useEntryPropsTabsContext } from '-/hooks/useEntryPropsTabsContext';import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';import { getEntryContainerTab } from '-/reducers/settings';@@ -37,10 +36,9 @@ function LinksTab(props: Props) {const { t } = useTranslation();const { findLocation } = useCurrentLocationContext();const { openedEntry, sharingLink, openLink } = useOpenedEntryContext();- const { isTabOpened } = useEntryPropsTabsContext();const { findLinks, checkIndexExist, isIndexing, createLocationIndex } =useLocationIndexContext();- const selectedTabIndex = useSelector(getEntryContainerTab);+ const selectedTabName = useSelector(getEntryContainerTab);const links = useRef<TS.Link[]>([]);const inboundLinks = useRef<TS.FileSystemEntry[]>([]);const indexExist = useRef<boolean>(false);@@ -49,46 +47,40 @@ function LinksTab(props: Props) {const location = findLocation(openedEntry.locationID);useEffect(() => {- isTabOpened(TabNames.linksTab, openedEntry, selectedTabIndex).then(- (linksTabOpened) => {- if (linksTabOpened) {- links.current = [];- inboundLinks.current = [];- indexExist.current = false;- // links from description- if (openedEntry.meta?.description) {- const descriptionLinks = extractLinks(openedEntry.meta.description);- if (descriptionLinks && descriptionLinks.length > 0) {- links.current = descriptionLinks;- }- }- forceUpdate();-- // links from file content- location- .checkFileEncryptedPromise(openedEntry.path)- .then((encrypted) => {- location- .getPropertiesPromise(openedEntry.path, encrypted, true)- .then((entryProps: TS.FileSystemEntry) => {- if (entryProps.links && entryProps.links.length > 0) {- links.current = [...links.current, ...entryProps.links];- forceUpdate();- }- });- });+ if (selectedTabName === TabNames.linksTab) {+ links.current = [];+ inboundLinks.current = [];+ indexExist.current = false;+ // links from description+ if (openedEntry.meta?.description) {+ const descriptionLinks = extractLinks(openedEntry.meta.description);+ if (descriptionLinks && descriptionLinks.length > 0) {+ links.current = descriptionLinks;+ }+ }+ forceUpdate();- // external (inbound) links- checkIndexExist(location.uuid).then((exist) => {- indexExist.current = exist;- if (exist) {- setInboundLinks();+ // links from file content+ location.checkFileEncryptedPromise(openedEntry.path).then((encrypted) => {+ location+ .getPropertiesPromise(openedEntry.path, encrypted, true)+ .then((entryProps: TS.FileSystemEntry) => {+ if (entryProps.links && entryProps.links.length > 0) {+ links.current = [...links.current, ...entryProps.links];+ forceUpdate();}});+ });++ // external (inbound) links+ checkIndexExist(location.uuid).then((exist) => {+ indexExist.current = exist;+ if (exist) {+ setInboundLinks();}- },- );- }, [openedEntry, selectedTabIndex]);+ });+ }+ }, [openedEntry, selectedTabName]);function refreshInboundLinks() {createLocationIndex(location).then(() => setInboundLinks());diff --git a/src/renderer/hooks/EntryPropsTabsContextProvider.tsx b/src/renderer/hooks/EntryPropsTabsContextProvider.tsxindex ea73268c7..5946386e0 100644--- a/src/renderer/hooks/EntryPropsTabsContextProvider.tsx+++ b/src/renderer/hooks/EntryPropsTabsContextProvider.tsx@@ -58,18 +58,18 @@ type EntryPropsTabsContextData = {tabName: (typeof TabNames)[keyof typeof TabNames],openedEntry: TS.OpenedEntry,) => Promise<number>;*/- isTabOpened: (+ /*isTabOpened: (tabName: (typeof TabNames)[keyof typeof TabNames],openedEntry: TS.OpenedEntry,selectedTabIndex: number,- ) => Promise<boolean>;+ ) => Promise<boolean>;*/};export const EntryPropsTabsContext = createContext<EntryPropsTabsContextData>({getTabsArray: undefined,isEditable: undefined,//setOpenedTab: undefined,- isTabOpened: undefined,+ //isTabOpened: undefined,});export type EntryPropsTabsContextProviderProps = {@@ -188,7 +188,7 @@ export const EntryPropsTabsContextProvider = ({return tabIndex;}*/- async function isTabOpened(+ /*async function isTabOpened(tabName: (typeof TabNames)[keyof typeof TabNames],openedEntry: TS.OpenedEntry,selectedTabIndex: number,@@ -199,14 +199,14 @@ export const EntryPropsTabsContextProvider = ({const currentOpenedTab =selectedTabIndex > maxTabIndex ? maxTabIndex : selectedTabIndex;return tabIndex !== -1 && tabIndex === currentOpenedTab;- }+ }*/const context = useMemo(() => {return {getTabsArray,isEditable,//setOpenedTab,- isTabOpened,+ //isTabOpened,};}, []);diff --git a/src/renderer/perspectives/common/CellView.tsx b/src/renderer/perspectives/common/CellView.tsxindex 607d19834..2659efc3e 100644--- a/src/renderer/perspectives/common/CellView.tsx+++ b/src/renderer/perspectives/common/CellView.tsx@@ -16,7 +16,7 @@**/-import React, { useEffect, useRef } from 'react';+import React from 'react';import { useSelector } from 'react-redux';import AppConfig from '-/AppConfig';import { TS } from '-/tagspaces.namespace';@@ -44,7 +44,6 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useNotificationContext } from '-/hooks/useNotificationContext';import { useEntryExistDialogContext } from '-/components/dialogs/hooks/useEntryExistDialogContext';import i18n from '-/services/i18n';-import { useEntryPropsTabsContext } from '-/hooks/useEntryPropsTabsContext';import { TabNames } from '-/hooks/EntryPropsTabsContextProvider';interface Props {@@ -80,7 +79,6 @@ function CellView(props: Props) {usePerspectiveSettingsContext();const theme = useTheme();const { openEntryInternal, openedEntry } = useOpenedEntryContext();- const { isTabOpened } = useEntryPropsTabsContext();const { openDirectory } = useDirectoryContentContext();const { moveFiles, openFileNatively } = useIOActionsContext();const { readOnlyMode, currentLocation } = useCurrentLocationContext();@@ -92,7 +90,7 @@ function CellView(props: Props) {const { showNotification } = useNotificationContext();const desktopMode = useSelector(getDesktopMode);- const selectedTabIndex = useSelector(getEntryContainerTab);+ const selectedTabName = useSelector(getEntryContainerTab);// const fileSourceRef = useRef<HTMLDivElement | null>(null);/*useEffect(() => {@@ -249,17 +247,9 @@ function CellView(props: Props) {setSelectedEntries([fsEntry]);if (fsEntry.isFile) {if (singleClickAction === 'openInternal') {- if (!openedEntry) {+ if (!openedEntry || selectedTabName !== TabNames.aiTab) {+ // dont open file if chat mode is enabledopenEntryInternal(fsEntry);- } else {- isTabOpened(TabNames.aiTab, openedEntry, selectedTabIndex).then(- (aiTabOpened) => {- // dont open file if chat mode is enabled- if (!aiTabOpened) {- openEntryInternal(fsEntry);- }- },- );}} else if (singleClickAction === 'openExternal') {openFileNatively(fsEntry.path);