Web:Files:Added a check for the absence of other pictures in the playlist for moving through the picture via a direct link in MediaViewer.

This commit is contained in:
Vlada Gazizova 2022-01-21 19:21:29 +03:00
parent 5dbe35f4d1
commit ee2fd6bb0f
4 changed files with 21 additions and 18 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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,
};