Web: Files: fixed withBadges, withContent HOCs re-render

This commit is contained in:
Nikita Gopienko 2022-02-28 15:46:06 +03:00
parent 2092430bcf
commit e5ba722f7c
4 changed files with 10 additions and 22 deletions

View File

@ -5,7 +5,6 @@ import {
AppServerConfig,
FileStatus,
} from "@appserver/common/constants";
import toastr from "@appserver/components/toast/toastr";
import { combineUrl } from "@appserver/common/utils";
import Badges from "../components/Badges";
@ -36,18 +35,11 @@ export default function withBadges(WrappedComponent) {
};
onBadgeClick = () => {
const {
item,
selectedFolderPathParts,
markAsRead,
setNewFilesPanelVisible,
} = this.props;
const { item, markAsRead, setNewFilesPanelVisible } = this.props;
if (item.fileExst) {
markAsRead([], [item.id], item);
} else {
const newFolderIds = selectedFolderPathParts;
newFolderIds.push(item.id);
setNewFilesPanelVisible(true, newFolderIds, item);
setNewFilesPanelVisible(true, null, item);
}
};
@ -115,7 +107,6 @@ export default function withBadges(WrappedComponent) {
treeFoldersStore,
filesActionsStore,
versionHistoryStore,
selectedFolderStore,
dialogsStore,
filesStore,
settingsStore,
@ -146,7 +137,6 @@ export default function withBadges(WrappedComponent) {
isTabletView,
setIsVerHistoryPanel,
fetchFileVersions,
selectedFolderPathParts: selectedFolderStore.pathParts,
markAsRead,
setNewFilesPanelVisible,
setIsLoading,

View File

@ -1,7 +1,5 @@
import React from "react";
import { inject, observer } from "mobx-react";
import { Trans } from "react-i18next";
import toastr from "studio/toastr";
import {
AppServerConfig,
@ -177,7 +175,6 @@ export default function withContent(WrappedContent) {
createFolder,
fileActionTemplateId,
isDesktop,
isLoading,
isPrivacy,
item,
openDocEditor,
@ -198,8 +195,6 @@ export default function withContent(WrappedContent) {
let title = itemTitle;
if (isLoading) return;
setIsLoading(true);
const itemId = e.currentTarget.dataset.itemid;
@ -461,7 +456,6 @@ export default function withContent(WrappedContent) {
const {
createFile,
createFolder,
isLoading,
openDocEditor,
renameFolder,
setIsLoading,
@ -511,7 +505,6 @@ export default function withContent(WrappedContent) {
folderFormValidation,
homepage: config.homepage,
isDesktop: isDesktopClient,
isLoading,
isPrivacy: isPrivacyFolder,
isTrashFolder: isRecycleBinFolder,
openDocEditor,

View File

@ -66,7 +66,7 @@ class ArticleBodyContent extends React.Component {
};
onShowNewFilesPanel = (folderId) => {
this.props.setNewFilesPanelVisible(true, [folderId]);
this.props.setNewFilesPanelVisible(true, folderId);
};
render() {

View File

@ -113,8 +113,13 @@ class DialogsStore {
this.destFolderId = destFolderId;
};
setNewFilesPanelVisible = async (visible, newIds, item) => {
const id = newIds && newIds[newIds.length - 1];
setNewFilesPanelVisible = async (visible, newId, item) => {
const { pathParts } = this.selectedFolderStore;
const id = visible && !newId ? item.id : newId;
const newIds = newId ? [newId] : pathParts;
item && pathParts.push(item.id);
let newFilesPanelVisible = visible;
if (visible) {