diff --git a/packages/asc-web-common/components/MediaViewer/MediaViewer.js b/packages/asc-web-common/components/MediaViewer/MediaViewer.js index a8fcaf5a64..9b8d932e5d 100644 --- a/packages/asc-web-common/components/MediaViewer/MediaViewer.js +++ b/packages/asc-web-common/components/MediaViewer/MediaViewer.js @@ -14,7 +14,7 @@ import Hammer from "hammerjs"; import IconButton from "@appserver/components/icon-button"; import commonIconsStyles from "@appserver/components/utils/common-icons-style"; import { isDesktop } from "react-device-detect"; -import history from "@appserver/common/history"; +//import history from "@appserver/common/history"; const StyledVideoViewer = styled(VideoViewer)` z-index: 301; @@ -220,7 +220,7 @@ class MediaViewer extends React.Component { } document.removeEventListener("keydown", this.onKeydown, false); document.removeEventListener("keyup", this.onKeyup, false); - this.onClose(); + //this.onClose(); } mapSupplied = { @@ -313,8 +313,7 @@ class MediaViewer extends React.Component { const id = playlist[currentPlaylistPos].fileId; const url = "/products/files/#preview/" + id; - //window.history.pushState(null, null, url); - history.push(url); + history.pushState({ id, type: "image" }, null, url); }; nextMedia = () => { @@ -330,8 +329,10 @@ class MediaViewer extends React.Component { const id = playlist[currentPlaylistPos].fileId; const url = "/products/files/#preview/" + id; - history.push(url); - //window.history.pushState(null, null, url); + history.pushState({ id, type: "image" }, null, url); + + console.log("history.state", history.state); + console.log("history.length", history.length); }; getOffset = () => { @@ -433,6 +434,7 @@ class MediaViewer extends React.Component { }; onClose = () => { + console.log("onClose"); this.props.onClose(); this.setState({ visible: false }); }; @@ -488,6 +490,7 @@ class MediaViewer extends React.Component { if (this.canImageView(ext)) { isImage = true; } else { + console.log("isVideo"); isImage = false; isVideo = this.mapSupplied[ext] ? this.mapSupplied[ext].type == mediaTypes.video diff --git a/products/ASC.Files/Client/src/HOCs/withFileActions.js b/products/ASC.Files/Client/src/HOCs/withFileActions.js index edc52e8078..df19f0f70a 100644 --- a/products/ASC.Files/Client/src/HOCs/withFileActions.js +++ b/products/ASC.Files/Client/src/HOCs/withFileActions.js @@ -6,7 +6,7 @@ import { AppServerConfig } from "@appserver/common/constants"; import { combineUrl } from "@appserver/common/utils"; import config from "../../package.json"; import { isMobile } from "react-device-detect"; -import history from "@appserver/common/history"; +//import history from "@appserver/common/history"; export default function withFileActions(WrappedFileItem) { class WithFileActions extends React.Component { @@ -154,10 +154,11 @@ export default function withFileActions(WrappedFileItem) { if (encrypted && isPrivacy) return checkProtocol(item.id, true); if (item.fileExst === ".png") { - const url = "/products/files/#preview/" + item.id; + const url = "/products/files/#preview/" + id; - //window.history.pushState(null, null, url); - history.push(url); + history.pushState({ id, type: "image" }, null, url); + console.log("history.state", history.state); + console.log("history.length", history.length); } if (isTrashFolder) return; diff --git a/products/ASC.Files/Client/src/pages/Home/MediaViewer/index.js b/products/ASC.Files/Client/src/pages/Home/MediaViewer/index.js index 35b0f92566..3a2c7fa05a 100644 --- a/products/ASC.Files/Client/src/pages/Home/MediaViewer/index.js +++ b/products/ASC.Files/Client/src/pages/Home/MediaViewer/index.js @@ -39,10 +39,6 @@ const FilesMediaViewer = (props) => { } }, [removeQuery, onMediaFileClick]); - useEffect(() => { - console.log("previewFile", previewFile); - }, [previewFile]); - const removeQuery = (queryName) => { const queryParams = new URLSearchParams(location.search); @@ -94,8 +90,6 @@ const FilesMediaViewer = (props) => { setIsLoading(true); setFirstLoad(true); - console.log("onMediaViewerClose"); - fetchFiles(previewFile.folderId) .then((data) => { const pathParts = data.selectedFolder.pathParts; diff --git a/products/ASC.Files/Client/src/pages/Home/index.js b/products/ASC.Files/Client/src/pages/Home/index.js index c2e91d6481..146f255145 100644 --- a/products/ASC.Files/Client/src/pages/Home/index.js +++ b/products/ASC.Files/Client/src/pages/Home/index.js @@ -38,6 +38,7 @@ class PureHome extends React.Component { expandedKeys, setExpandedKeys, setToPreviewFile, + playlist, mediaViewersFormatsStore, getFileInfo, } = this.props; @@ -46,7 +47,10 @@ class PureHome extends React.Component { const match = window.location.pathname.match(reg); let filterObj = null; - if (window.location.href.indexOf("/files/#preview") > 1) { + if ( + window.location.href.indexOf("/files/#preview") > 1 && + playlist.length < 1 + ) { const pathname = window.location.href; const fileId = pathname.slice(pathname.indexOf("#preview") + 9); @@ -393,7 +397,7 @@ export default inject( ? filesStore.selectionTitle : null; - const { setToPreviewFile } = mediaViewerDataStore; + const { setToPreviewFile, playlist } = mediaViewerDataStore; if (!firstLoad) { if (isLoading) { showLoader(); @@ -441,6 +445,7 @@ export default inject( isHeaderVisible: auth.settingsStore.isHeaderVisible, setHeaderVisible: auth.settingsStore.setHeaderVisible, setToPreviewFile, + playlist, mediaViewersFormatsStore, getFileInfo, };