Skip to content

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

chore: enable displaying of the sidecar file revisions

Ilian Sapundshievce098b53afd7
diff --git a/src/renderer/components/dialogs/FilePreviewDialog.tsx b/src/renderer/components/dialogs/FilePreviewDialog.tsx
index b16a3a8a1..41345733c 100644
--- a/src/renderer/components/dialogs/FilePreviewDialog.tsx
+++ b/src/renderer/components/dialogs/FilePreviewDialog.tsx
@@ -23,7 +23,8 @@ import TsDialogTitle from '-/components/dialogs/components/TsDialogTitle';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useFilePropertiesContext } from '-/hooks/useFilePropertiesContext';
import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
-import { getCurrentTheme } from '-/reducers/settings';
+import { getCurrentTheme, getSupportedFileTypes } from '-/reducers/settings';
+import { findExtensionPathForId } from '-/services/utils-io';
import { TS } from '-/tagspaces.namespace';
import { Typography } from '@mui/material';
import Dialog from '@mui/material/Dialog';
@@ -42,6 +43,7 @@ interface Props {
function FilePreviewDialog(props: Props) {
const { open = false, onClose, fsEntry } = props;
+ const supportedFileTypes = useSelector(getSupportedFileTypes);
const { findLocation } = useCurrentLocationContext();
const { openedEntry } = useOpenedEntryContext();
const { isEditMode } = useFilePropertiesContext();
@@ -63,6 +65,27 @@ function FilePreviewDialog(props: Props) {
}
: undefined;
+ if (fsEntry?.name?.endsWith('meta')) {
+ const fileType: TS.FileTypes = supportedFileTypes.find(
+ (fileType) => fileType.viewer && fileType.type.toLowerCase() === 'json',
+ );
+ if (fileType) {
+ openedEntry.isFile = true;
+ openedEntry.viewingExtensionId = fileType.viewer;
+ openedEntry.viewingExtensionPath = findExtensionPathForId(
+ fileType.viewer,
+ fileType.extensionExternalPath,
+ );
+ // if (fileType.editor && fileType.editor.length > 0) {
+ // openedEntry.editingExtensionId = fileType.editor;
+ // openedEntry.editingExtensionPath = findExtensionPathForId(
+ // fileType.editor,
+ // fileType.extensionExternalPath,
+ // );
+ // }
+ }
+ }
+
const handleMessage = (data: any) => {
if (!openedFile || !openedFile.path) {
return;