From 045826e073d348a3ab2f72ebeb03349f1e307f7f Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Thu, 5 May 2022 12:13:32 +0300 Subject: [PATCH] Web: Files: fix show prev file in the version history --- .../panels/VersionHistoryPanel/index.js | 15 ++--------- .../Client/src/pages/VersionHistory/index.js | 26 ------------------- .../Client/src/store/VersionHistoryStore.js | 13 +++++++--- 3 files changed, 12 insertions(+), 42 deletions(-) diff --git a/products/ASC.Files/Client/src/components/panels/VersionHistoryPanel/index.js b/products/ASC.Files/Client/src/components/panels/VersionHistoryPanel/index.js index f92cc8ec69..61f25d17c1 100644 --- a/products/ASC.Files/Client/src/components/panels/VersionHistoryPanel/index.js +++ b/products/ASC.Files/Client/src/components/panels/VersionHistoryPanel/index.js @@ -18,20 +18,9 @@ import { inject, observer } from "mobx-react"; import config from "../../../../package.json"; class PureVersionHistoryPanel extends React.Component { - componentDidUpdate(preProps) { - const { isTabletView, fileId } = this.props; - if (isTabletView !== preProps.isTabletView && isTabletView) { - this.redirectToPage(fileId); - } - } - - redirectToPage = (fileId) => { - this.onClose(); - history.replace(`${this.props.homepage}/${fileId}/history`); - }; - onClose = () => { - this.props.setIsVerHistoryPanel(false); + const { setIsVerHistoryPanel } = this.props; + setIsVerHistoryPanel(false); }; render() { diff --git a/products/ASC.Files/Client/src/pages/VersionHistory/index.js b/products/ASC.Files/Client/src/pages/VersionHistory/index.js index c0bbb1eca1..51e78b602b 100644 --- a/products/ASC.Files/Client/src/pages/VersionHistory/index.js +++ b/products/ASC.Files/Client/src/pages/VersionHistory/index.js @@ -10,32 +10,6 @@ import { SectionHeaderContent, SectionBodyContent } from "./Section"; import { inject, observer } from "mobx-react"; class PureVersionHistory extends React.Component { - componentDidMount() { - const { isTabletView } = this.props; - - if (!isTabletView) { - this.redirectToPanelView(); - } - } - - componentDidUpdate(prevProps) { - const { isTabletView } = this.props; - if (isTabletView !== prevProps.isTabletView && !isTabletView) { - this.redirectToPanelView(); - } - } - - redirectToPanelView = () => { - const { setIsVerHistoryPanel } = this.props; - setIsVerHistoryPanel(true); - this.redirectToHomepage(); - }; - - redirectToHomepage = () => { - const { history } = this.props; - history.goBack(); - }; - render() { const { isLoading, versions, showProgressBar } = this.props; diff --git a/products/ASC.Files/Client/src/store/VersionHistoryStore.js b/products/ASC.Files/Client/src/store/VersionHistoryStore.js index 38a8f7737c..0f2c4b74b8 100644 --- a/products/ASC.Files/Client/src/store/VersionHistoryStore.js +++ b/products/ASC.Files/Client/src/store/VersionHistoryStore.js @@ -16,8 +16,7 @@ class VersionHistoryStore { makeAutoObservable(this); this.filesStore = filesStore; - const isTabletView = window.innerWidth <= size.tablet; - if (isTabletView && this.versions) { + if (this.versions) { //TODO: Files store in not initialized on versionHistory page. Need socket. const { socketHelper } = this.filesStore.settingsStore; @@ -52,13 +51,21 @@ class VersionHistoryStore { setIsVerHistoryPanel = (isVisible) => { this.isVisible = isVisible; - !isVisible && this.setVerHistoryFileId(null); + + if (!isVisible) { + this.setVersions(null); + this.setVerHistoryFileId(null); + } }; setVerHistoryFileId = (fileId) => { this.fileId = fileId; }; + setVersions = (versions) => { + this.versions = versions; + }; + //setFileVersions setVerHistoryFileVersions = (versions) => { const file = this.filesStore.files.find((item) => item.id == this.fileId);