Web:Viewer Fixed bug and Refactoring, does not change the URL after closing the viewer if the viewer was opened through the context menu

This commit is contained in:
Akmal Isomadinov 2023-05-03 13:13:37 +05:00
parent 70cd7840d3
commit ac5df5c2ff
5 changed files with 31 additions and 10 deletions

View File

@ -48,6 +48,7 @@ const FilesMediaViewer = (props) => {
nextMedia,
prevMedia,
resetUrl,
getFirstUrl,
firstLoad,
setSelection,
} = props;
@ -160,7 +161,8 @@ const FilesMediaViewer = (props) => {
setMediaViewerData({ visible: false, id: null });
const url = localStorage.getItem("isFirstUrl");
// const url = localStorage.getItem("isFirstUrl");
const url = getFirstUrl();
if (!url) {
return;
@ -238,6 +240,7 @@ export default inject(
id: currentMediaFileId,
currentPostionIndex,
setMediaViewerData,
getFirstUrl,
playlist,
previewFile,
setToPreviewFile,
@ -302,6 +305,7 @@ export default inject(
onDuplicate,
archiveRoomsId,
setSelection,
getFirstUrl,
};
}
)(

View File

@ -53,10 +53,13 @@ class PureHome extends React.Component {
setIsUpdatingRowItem,
setIsPreview,
selectedFolderStore,
removeFirstUrl,
} = this.props;
if (!window.location.href.includes("#preview")) {
localStorage.removeItem("isFirstUrl");
// localStorage.removeItem("isFirstUrl");
// Media viewer
removeFirstUrl();
}
const categoryType = getCategoryType(location);
@ -680,12 +683,8 @@ export default inject(
setItemsSelectionTitle,
} = secondaryProgressDataStore;
const {
setUploadPanelVisible,
startUpload,
uploaded,
converted,
} = uploadDataStore;
const { setUploadPanelVisible, startUpload, uploaded, converted } =
uploadDataStore;
const { uploadEmptyFolders } = filesActionsStore;
@ -694,7 +693,7 @@ export default inject(
? filesStore.selectionTitle
: null;
const { setToPreviewFile, playlist } = mediaViewerDataStore;
const { setToPreviewFile, playlist, removeFirstUrl } = mediaViewerDataStore;
const {
isHeaderVisible,
@ -766,6 +765,7 @@ export default inject(
setToPreviewFile,
setIsPreview,
playlist,
removeFirstUrl,
getFileInfo,
gallerySelected,

View File

@ -400,6 +400,8 @@ class ContextOptionsStore {
onMediaFileClick = (fileId, item) => {
const itemId = typeof fileId !== "object" ? fileId : item.id;
this.mediaViewerDataStore.setMediaViewerData({ visible: true, id: itemId });
// localStorage.setItem("isFirstUrl", window.location.href);
this.mediaViewerDataStore.saveFirstUrl(window.location.href);
this.mediaViewerDataStore.changeUrl(itemId);
};

View File

@ -1978,7 +1978,8 @@ class FilesActionStore {
}
if (isMediaOrImage) {
localStorage.setItem("isFirstUrl", window.location.href);
// localStorage.setItem("isFirstUrl", window.location.href);
this.mediaViewerDataStore.saveFirstUrl(window.location.href);
setMediaViewerData({ visible: true, id });
const url = "/products/files/#preview/" + id;

View File

@ -4,6 +4,8 @@ import {
findNearestIndex,
} from "@docspace/common/components/MediaViewer/helpers";
const FirstUrlKey = "isFirstUrl";
class MediaViewerDataStore {
filesStore;
settingsStore;
@ -50,6 +52,18 @@ class MediaViewerDataStore {
this.id = id;
};
saveFirstUrl = (url) => {
localStorage.setItem(FirstUrlKey, url);
};
getFirstUrl = () => {
return localStorage.getItem(FirstUrlKey);
};
removeFirstUrl = () => {
localStorage.removeItem(FirstUrlKey);
};
changeUrl = (id) => {
const url = "/products/files/#preview/" + id;
window.history.pushState(null, null, url);