Skip to content

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

fix Restoring revision do not update the file in the viewer (#2103)

Stanimir401dd59212d0
diff --git a/src/renderer/components/Revisions.tsx b/src/renderer/components/Revisions.tsx
index ac25ee2e4..e71b47a33 100644
--- a/src/renderer/components/Revisions.tsx
+++ b/src/renderer/components/Revisions.tsx
@@ -57,7 +57,7 @@ function Revisions() {
const { t } = useTranslation();
const { findLocation } = useCurrentLocationContext();
const { getMetadataID } = useIOActionsContext();
- const { openedEntry } = useOpenedEntryContext();
+ const { openedEntry, reloadOpenedFile } = useOpenedEntryContext();
const { copyFilePromiseOverwrite } = usePlatformFacadeContext();
const [rows, setRows] = useState<Array<TS.FileSystemEntry>>([]);
const [page, setPage] = useState<number>(0);
@@ -143,15 +143,9 @@ function Revisions() {
location.getDirSeparator(),
);
return copyFilePromiseOverwrite(openedEntry.path, targetPath).then(() =>
- copyFilePromiseOverwrite(revisionPath, openedEntry.path).then(() => {
- /*const fsMeta = {
- id: '',
- ...openedEntry,
- editMode: false,
- shouldReload: !openedEntry.shouldReload,
- };
- updateOpenedFile(openedEntry.path, fsMeta);*/
- }),
+ copyFilePromiseOverwrite(revisionPath, openedEntry.path).then(() =>
+ reloadOpenedFile(),
+ ),
);
}
function titleFormat(lmdt) {
diff --git a/src/renderer/hooks/DirectoryContentContextProvider.tsx b/src/renderer/hooks/DirectoryContentContextProvider.tsx
index d2e334479..72f936cbb 100644
--- a/src/renderer/hooks/DirectoryContentContextProvider.tsx
+++ b/src/renderer/hooks/DirectoryContentContextProvider.tsx
@@ -353,12 +353,18 @@ export const DirectoryContentContextProvider = ({
(entry) => entry.path === action.entry.path,
)
) {
- if (selectedEntries.length > 0) {
- selected = [...selectedEntries, action.entry];
- } else {
- selected.push(action.entry);
+ if (
+ !selectedEntries.some(
+ (entry) => entry.path === action.entry.path,
+ )
+ ) {
+ if (selectedEntries.length > 0) {
+ selected = [...selectedEntries, action.entry];
+ } else {
+ selected.push(action.entry);
+ }
+ updated = true;
}
- updated = true;
}
} else if (action.action === 'delete') {
let index = selectedEntries.findIndex(