TagSpaces is an offline, open source, document manager with tagging support
fix various issues
sytolkdb3f28c0c087
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsxindex 4fe761789..1786463fb 100644--- a/app/components/EntryContainer.tsx+++ b/app/components/EntryContainer.tsx@@ -914,7 +914,6 @@ function EntryContainer() {><EntryContainerTitleisFileChanged={fileChanged.current}- openedFile={openedFile}reloadDocument={reloadDocument}toggleFullScreen={toggleFullScreen}/>diff --git a/app/components/EntryContainerTabs.tsx b/app/components/EntryContainerTabs.tsxindex 146b456e2..0b0b596c6 100644--- a/app/components/EntryContainerTabs.tsx+++ b/app/components/EntryContainerTabs.tsx@@ -57,7 +57,6 @@ const StyledTabs = styled((props: StyledTabsProps) => (variant="scrollable"scrollButtons="auto"allowScrollButtonsMobile- selectionFollowsFocusTabIndicatorProps={{ children: <span className="MuiTabs-indicatorSpan" /> }}/>))(({ theme }) => ({diff --git a/app/components/EntryContainerTitle.tsx b/app/components/EntryContainerTitle.tsxindex 442cecb80..9e5366fc2 100644--- a/app/components/EntryContainerTitle.tsx+++ b/app/components/EntryContainerTitle.tsx@@ -35,7 +35,6 @@ import PlatformIO from '-/services/platform-facade';import { FolderIcon, MoreMenuIcon } from '-/components/CommonIcons';import AppConfig from '-/AppConfig';import EntryContainerMenu from '-/components/EntryContainerMenu';-import { getSharingLink, loadJSONFile } from '-/services/utils-io';import { useDispatch, useSelector } from 'react-redux';import { getLocations } from '-/reducers/locations';import Box from '@mui/material/Box';@@ -47,6 +46,7 @@ import BookmarkAddIcon from '@mui/icons-material/BookmarkAddTwoTone';import TagsPreview from '-/components/TagsPreview';import { Pro } from '-/pro';import { useTranslation } from 'react-i18next';+import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';const FileBadge = styled('span')(({ theme }) => ({color: 'white',@@ -59,23 +59,24 @@ const FileBadge = styled('span')(({ theme }) => ({}));interface Props {- openedFile: OpenedEntry;isFileChanged: boolean;toggleFullScreen: () => void;reloadDocument: () => void;}function EntryContainerTitle(props: Props) {- const { openedFile, isFileChanged, reloadDocument, toggleFullScreen } = props;+ const { isFileChanged, reloadDocument, toggleFullScreen } = props;const { t } = useTranslation();const theme = useTheme();+ const {+ openedEntries,+ sharingLink,+ sharingParentFolderLink+ } = useOpenedEntryContext();+ const openedFile = openedEntries[0];const dispatch: AppDispatch = useDispatch();const locations = useSelector(getLocations);const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);- const { sharingLink, sharingParentFolderLink } = getSharingLink(- openedFile,- locations- );const [ignored, forceUpdate] = useReducer(x => x + 1, 0);const haveBookmark =diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsxindex f9114bd47..e12fa5b05 100644--- a/app/components/EntryProperties.tsx+++ b/app/components/EntryProperties.tsx@@ -64,8 +64,7 @@ import {enhanceOpenedEntry,fileNameValidation,dirNameValidation,- normalizeUrl,- getSharingLink+ normalizeUrl} from '-/services/utils-io';import { getUuid } from '@tagspaces/tagspaces-common/utils-io';import { parseGeoLocation } from '-/utils/geo';@@ -219,7 +218,11 @@ const defaultBackgrounds = [function EntryProperties(props: Props) {const { t } = useTranslation();const theme = useTheme();- const { openedEntries, updateOpenedFile } = useOpenedEntryContext();+ const {+ openedEntries,+ updateOpenedFile,+ sharingLink+ } = useOpenedEntryContext();const { renameDirectory } = useFsActionsContext();const { addTags, removeTags, removeAllTags } = useTaggingActionsContext();const fileNameRef = useRef<HTMLInputElement>(null);@@ -697,10 +700,6 @@ function EntryProperties(props: Props) {currentEntry.current.url && currentEntry.current.url.length > 5;const showLinkForDownloading = isCloudLocation && currentEntry.current.isFile;- const { sharingLink, sharingParentFolderLink } = getSharingLink(- currentEntry.current,- props.locations- );return (<Root>diff --git a/app/hooks/OpenedEntryContextProvider.tsx b/app/hooks/OpenedEntryContextProvider.tsxindex 93f62b81d..2a16de176 100644--- a/app/hooks/OpenedEntryContextProvider.tsx+++ b/app/hooks/OpenedEntryContextProvider.tsx@@ -16,7 +16,13 @@**/-import React, { createContext, useEffect, useMemo, useState } from 'react';+import React, {+ createContext,+ useEffect,+ useMemo,+ useRef,+ useState+} from 'react';import { useDispatch, useSelector } from 'react-redux';import {actions as AppActions,@@ -52,6 +58,7 @@ import {import { getCurrentLocation, getLocations } from '-/reducers/locations';import { clearURLParam, getURLParameter, updateHistory } from '-/utils/dom';import {+ cleanRootPath,extractContainingDirectoryPath,extractTagsAsObjects,generateSharingLink,@@ -72,6 +79,8 @@ import useFirstRender from '-/utils/useFirstRender';type OpenedEntryContextData = {openedEntries: OpenedEntry[];isEntryInFullWidth: boolean;+ sharingLink: string;+ sharingParentFolderLink: string;setEntryInFullWidth: (fullWidth: boolean) => void;addToEntryContainer: (fsEntry: OpenedEntry) => void;closeAllFiles: () => void;@@ -101,6 +110,8 @@ type OpenedEntryContextData = {export const OpenedEntryContext = createContext<OpenedEntryContextData>({openedEntries: [],isEntryInFullWidth: false,+ sharingLink: undefined,+ sharingParentFolderLink: undefined,setEntryInFullWidth: () => {},addToEntryContainer: () => {},closeAllFiles: () => {},@@ -147,6 +158,8 @@ export const OpenedEntryContextProvider = ({const enableGlobalKeyboardShortcuts = useSelector(isGlobalKeyBindingEnabled);*/const [openedEntries, setOpenedEntries] = useState([]);const [isEntryInFullWidth, setEntryInFullWidth] = useState(false);+ const sharingLink = useRef<string>(undefined);+ const sharingParentFolderLink = useRef<string>(undefined);const firstRender = useFirstRender();/**@@ -198,6 +211,7 @@ export const OpenedEntryContextProvider = ({// shouldReload: true};});+ setSharedLinks(newEntries[0]);setOpenedEntries(newEntries);}} else if (action === 'delete') {@@ -213,6 +227,53 @@ export const OpenedEntryContextProvider = ({}}, [editedEntryPaths]);+ function setSharedLinks(openedFile?) {+ if (openedFile) {+ if (window.location.href.indexOf('?') > 0) {+ const sharingURL = new URL(window.location.href);+ const params = new URLSearchParams(sharingURL.search);+ if (params.has('tslid')) {+ const locationId = params.get('tslid');+ //if (params.has('tsdpath')) {+ // const folderPath2 = params.get('tsdpath');+ const folderLocation = locations.find(+ location => location.uuid === locationId+ );+ const folderPath = extractContainingDirectoryPath(openedFile.path);+ if (folderPath.indexOf(folderLocation.path) === 0) {+ sharingParentFolderLink.current = generateSharingLink(+ locationId,+ undefined,+ cleanRootPath(+ folderPath,+ folderLocation.path,+ PlatformIO.getDirSeparator()+ )+ );+ }++ //}+ if (params.has('tsepath')) {+ const entryPath = params.get('tsepath');+ if (openedFile.isFile) {+ sharingLink.current = generateSharingLink(locationId, entryPath);+ } else {+ sharingLink.current = generateSharingLink(+ locationId,+ undefined,+ entryPath+ );+ }+ } else {+ sharingLink.current = generateSharingLink(locationId);+ }+ }+ }+ } else {+ sharingLink.current = undefined;+ sharingParentFolderLink.current = undefined;+ }+ }/*function initApp() {disableBackGestureMac();// migrate TagLibrary from redux state@@ -274,10 +335,12 @@ export const OpenedEntryContextProvider = ({}*/function addToEntryContainer(fsEntry: OpenedEntry) {+ setSharedLinks(fsEntry);setOpenedEntries([fsEntry]); // [...openedEntries, fsEntry] // TODO uncomment for multiple file support}function closeOpenedEntries() {+ setSharedLinks();setOpenedEntries([]);}@@ -898,6 +961,8 @@ export const OpenedEntryContextProvider = ({return {openedEntries,isEntryInFullWidth,+ sharingLink: sharingLink.current,+ sharingParentFolderLink: sharingParentFolderLink.current,setEntryInFullWidth,addToEntryContainer,closeAllFiles,@@ -915,7 +980,12 @@ export const OpenedEntryContextProvider = ({reflectRenameDirectory,reflectDeleteDirectory};- }, [openedEntries, isEntryInFullWidth]);+ }, [+ openedEntries,+ isEntryInFullWidth,+ currentLocation,+ currentDirectoryPath+ ]);return (<OpenedEntryContext.Provider value={context}>diff --git a/app/services/utils-io.ts b/app/services/utils-io.tsindex 1bff6f4d9..0e398cf15 100644--- a/app/services/utils-io.ts+++ b/app/services/utils-io.ts@@ -1787,7 +1787,7 @@ export function openURLExternally(url: string, skipConfirmation = false) {}}-export function getSharingLink(+/*export function getSharingLink(openedFile: OpenedEntry,locations: Array<TS.Location>) {@@ -1830,4 +1830,4 @@ export function getSharingLink(}}return { sharingLink, sharingParentFolderLink };-}+}*/