TagSpaces is an offline, open source, document manager with tagging support
fix: issue with local file in the edited files history
Ilian Sapundshievee5c8e3965ef
diff --git a/src/renderer/components/EntryContainer.tsx b/src/renderer/components/EntryContainer.tsxindex 274382390..277f0d107 100644--- a/src/renderer/components/EntryContainer.tsx+++ b/src/renderer/components/EntryContainer.tsx@@ -66,17 +66,11 @@ import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';import { useNotificationContext } from '-/hooks/useNotificationContext';-import { toFsEntry } from '-/services/utils-io';+import { getRelativeEntryPath, toFsEntry } from '-/services/utils-io';import { usePlatformFacadeContext } from '-/hooks/usePlatformFacadeContext';import { SaveIcon, EditIcon } from '-/components/CommonIcons';import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';-//const defaultSplitSize = '7.86%'; // '7.2%'; // 103;-// const bufferedSplitResize = buffer({-// timeout: 300,-// id: 'buffered-split-resize'-// });-const historyKeys = Pro && Pro.history ? Pro.history.historyKeys : {};function EntryContainer() {@@ -95,7 +89,8 @@ function EntryContainer() {const { setAutoSave } = useEditedEntryMetaContext();const { readOnlyMode, switchLocationTypeByID, switchCurrentLocationType } =useCurrentLocationContext();- const { openDirectory, currentDirectoryPath } = useDirectoryContentContext();+ const { openDirectory, currentDirectoryPath, currentLocationPath } =+ useDirectoryContentContext();const { copyFilePromiseOverwrite, copyFilePromise, saveTextFilePromise } =usePlatformFacadeContext();const { showNotification } = useNotificationContext();@@ -107,8 +102,6 @@ function EntryContainer() {const desktopMode = useSelector(isDesktopMode);const revisionsEnabled = useSelector(isRevisionsEnabled);const theme = useTheme();- // const [percent, setPercent] = React.useState<number | undefined>(undefined);- // const percent = useRef<number | undefined>(undefined);const timer = useRef<NodeJS.Timeout>(null);const openedPanelStyle: React.CSSProperties = {@@ -119,13 +112,9 @@ function EntryContainer() {tabIndex !== undefined,);- /*const [isRevisionPanelVisible, setRevisionPanelVisible] = useState<boolean>(- false- );*/const [isFullscreen, setFullscreen] = useState<boolean>(false);// eslint-disable-next-line no-unused-varsconst [ignored, forceUpdate] = useReducer((x) => x + 1, 0);- // const [editingSupported, setEditingSupported] = useState<boolean>(true);const [isSaveBeforeCloseConfirmDialogOpened,setSaveBeforeCloseConfirmDialogOpened,@@ -147,7 +136,6 @@ function EntryContainer() {useRef<HTMLDivElement>(null);const fileChanged = useRef<boolean>(false);const eventID = useRef<string>(getUuid());- // const firstRender = useFirstRender();useEventListener('message', (e) => {if (typeof e.data === 'string') {@@ -216,13 +204,6 @@ function EntryContainer() {}}, [isFullscreen]);- /*useEffect(() => {- // description is saved as Preview- if (isPropertiesPanelVisible && openedEntry.description) {- reloadOpenedFile();- }- }, [isPropertiesPanelVisible]);*/-useEffect(() => {if (fscreen.fullscreenEnabled) {fscreen.addEventListener(@@ -409,43 +390,6 @@ function EntryContainer() {}};- /*const reloadOpenedFile = () => {- if (openedEntry) {- const metaFilePath = openedEntry.isFile- ? getMetaFileLocationForFile(- openedEntry.path,- PlatformIO.getDirSeparator()- )- : getMetaFileLocationForDir(- openedEntry.path,- PlatformIO.getDirSeparator()- );- try {- loadJSONFile(metaFilePath)- .then(fsEntryMeta => {- updateOpenedFile(openedEntry.path, {- ...fsEntryMeta,- editMode: false,- shouldReload: !openedEntry.shouldReload- });- })- .catch(() =>- updateOpenedFile(openedEntry.path, {- ...openedEntry,- editMode: false,- shouldReload: !openedEntry.shouldReload- })- );- } catch (e) {- updateOpenedFile(openedEntry.path, {- ...openedEntry,- editMode: false,- shouldReload: !openedEntry.shouldReload- });- }- }- };*/-const reloadDocument = () => {if (openedEntry) {if (openedEntry.editMode && fileChanged.current) {@@ -589,11 +533,15 @@ function EntryContainer() {.then((entry) => {reflectUpdateOpenedFileContent(entry);if (Pro) {+ const relativePath = getRelativeEntryPath(+ currentLocationPath,+ fileOpen.path,+ );Pro.history.saveHistory(historyKeys.fileEditKey,{- path: fileOpen.path,- url: generateSharingLink(fileOpen.locationId, fileOpen.path),+ path: relativePath,+ url: generateSharingLink(fileOpen.locationId, relativePath),lid: fileOpen.locationId,},fileEditHistoryKey,