TagSpaces is an offline, open source, document manager with tagging support
fix Issue with previews image tmbs on windows
Stanimirce4389555d6b
diff --git a/src/renderer/components/EntryContainer.tsx b/src/renderer/components/EntryContainer.tsxindex c8e7e48af..5011c71e1 100644--- a/src/renderer/components/EntryContainer.tsx+++ b/src/renderer/components/EntryContainer.tsx@@ -748,10 +748,6 @@ function EntryContainer() {height={tabIndex !== TabNames.closedTabs ? '100%' : 'calc(100% - 100px)'}- setSavingInProgress={(isSaving: boolean) => {- isSavingInProgress.current = isSaving;- forceUpdate();- }}handleMessage={handleMessage}/>)}diff --git a/src/renderer/components/FileView.tsx b/src/renderer/components/FileView.tsxindex 9fc31d670..a264d97ab 100644--- a/src/renderer/components/FileView.tsx+++ b/src/renderer/components/FileView.tsx@@ -18,7 +18,6 @@import AppConfig from '-/AppConfig';import { CloseIcon } from '-/components/CommonIcons';-import { useResolveConflictContext } from '-/components/dialogs/hooks/useResolveConflictContext';import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';import { useFilePropertiesContext } from '-/hooks/useFilePropertiesContext';import { useFullScreenContext } from '-/hooks/useFullScreenContext';@@ -33,40 +32,31 @@ import {useEffect,useReducer,useRef,- useState,} from 'react';import { useTranslation } from 'react-i18next';-import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';interface Props {fileViewer: MutableRefObject<HTMLIFrameElement>;fileViewerContainer: MutableRefObject<HTMLDivElement>;handleMessage: (obj: any) => void;- setSavingInProgress?: (isSaving: boolean) => void;height?: string;}function FileView(props: Props) {const { i18n } = useTranslation();const theme = useTheme();- const { openedEntry, fileChanged, setFileChanged } = useOpenedEntryContext();- const { saveFileOpen } = useResolveConflictContext();+ const { openedEntry } = useOpenedEntryContext();+ //const { saveFileOpen } = useResolveConflictContext();const { isEditMode } = useFilePropertiesContext();const { setFullscreen, isFullscreen, toggleFullScreen } =useFullScreenContext();const { searchQuery, isSearchMode } = useDirectoryContentContext();- const { findLocation } = useCurrentLocationContext();- const {- fileViewer,- fileViewerContainer,- height,- setSavingInProgress,- handleMessage,- } = props;++ const { fileViewer, fileViewerContainer, height, handleMessage } = props;const eventID = useRef<string>(getUuid());- const [thumb, setThumb] = useState<string | null>(null);- const [loadingThumb, setLoadingThumb] = useState(true);+ // const [thumb, setThumb] = useState<string | null>(null);+ // const [loadingThumb, setLoadingThumb] = useState(true);const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);useEffect(() => {@@ -100,7 +90,7 @@ function FileView(props: Props) {};}, []);- useEffect(() => {+ /*useEffect(() => {setLoadingThumb(true);const loc = findLocation(openedEntry.locationID);loc@@ -111,7 +101,7 @@ function FileView(props: Props) {.finally(() => {setLoadingThumb(false);});- }, [openedEntry]);+ }, [openedEntry]);*/const handleFullscreenChange = useCallback((e) => {let change = '';@@ -170,7 +160,7 @@ function FileView(props: Props) {}});- const savingFile = (force = false) => {+ /*const savingFile = (force = false) => {try {if (fileViewer &&@@ -202,7 +192,7 @@ function FileView(props: Props) {setSavingInProgress(false);console.debug('function getContent not exist for file:', e);}- };+ };*/function getFileOpenerURL(): string {if (openedEntry && openedEntry.path) {@@ -237,7 +227,9 @@ function FileView(props: Props) {: '';const locale = '&locale=' + i18n.language;- const thumbParam = thumb ? '&thumb=' + encodeURIComponent(thumb) : '';+ const thumbParam = openedEntry?.meta?.thumbPath+ ? '&thumb=' + encodeURIComponent(openedEntry.meta.thumbPath)+ : '';const theming ='&theme=' +theme.palette.mode +@@ -301,7 +293,7 @@ function FileView(props: Props) {<span>ESC</span></div>)}- {openedEntry.isFile && !loadingThumb && (+ {openedEntry.isFile && ( //!loadingThumb && (<iframeref={fileViewer}style={{diff --git a/src/renderer/hooks/OpenedEntryContextProvider.tsx b/src/renderer/hooks/OpenedEntryContextProvider.tsxindex 8fefced3f..4d043b936 100644--- a/src/renderer/hooks/OpenedEntryContextProvider.tsx+++ b/src/renderer/hooks/OpenedEntryContextProvider.tsx@@ -631,18 +631,28 @@ export const OpenedEntryContextProvider = ({entryForOpening.url = fsEntry.url;}//set meta and generate new meta id if not exist- if (fsEntry.isFile && (!fsEntry.meta || !fsEntry.meta.id)) {- const meta: TS.FileSystemEntryMeta = await getMetadata(- fsEntry.path,- fsEntry.uuid,- loc,- );- if (meta) {- entryForOpening.uuid = meta.id;- entryForOpening.meta = { ...(fsEntry.meta || {}), ...meta };+ if (fsEntry.isFile) {+ if (!fsEntry.meta?.id) {+ const meta: TS.FileSystemEntryMeta = await getMetadata(+ fsEntry.path,+ fsEntry.uuid,+ loc,+ );+ if (meta) {+ entryForOpening.uuid = meta.id;+ entryForOpening.meta = { ...fsEntry.meta, ...meta };+ }+ }+ if (fsEntry.meta?.thumbPath) {+ const thumb = await loc?.getThumbPath(+ fsEntry.meta.thumbPath,+ fsEntry.meta.lastUpdated,+ );+ if (thumb) {+ entryForOpening.meta.thumbPath = thumb;+ }}}-if (fsEntry.isNewFile &&AppConfig.editableFiles.includes(fsEntry.extension)diff --git a/src/renderer/utils/CommonLocation.ts b/src/renderer/utils/CommonLocation.tsindex 2a252f600..01086994e 100644--- a/src/renderer/utils/CommonLocation.ts+++ b/src/renderer/utils/CommonLocation.ts@@ -162,7 +162,11 @@ export class CommonLocation implements TS.Location {normalizedUrl = url.replaceAll(this.getDirSeparator(), '/');}}- if (!normalizedUrl.startsWith('http') && !normalizedUrl.startsWith('/')) {+ if (+ !normalizedUrl.startsWith('http') &&+ !AppConfig.isWin &&+ !normalizedUrl.startsWith('/')+ ) {normalizedUrl = '/' + normalizedUrl;}return normalizedUrl;