From 1d2ba0d5de6b96523d3cd0da04794e803d45af11 Mon Sep 17 00:00:00 2001 From: Daniil Senkiv Date: Tue, 8 Oct 2019 10:34:09 +0300 Subject: [PATCH] Web.Components/Client: Layout: fixed missing render in profile-actions sub-component in the case of changing user data or avatar --- web/ASC.Web.Client/src/components/Layout/index.js | 11 ++++------- web/ASC.Web.Components/src/components/layout/index.js | 3 ++- .../layout/sub-components/profile-actions.js | 5 +++++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/web/ASC.Web.Client/src/components/Layout/index.js b/web/ASC.Web.Client/src/components/Layout/index.js index 41bff0ae6a..00aaedbec6 100644 --- a/web/ASC.Web.Client/src/components/Layout/index.js +++ b/web/ASC.Web.Client/src/components/Layout/index.js @@ -6,15 +6,12 @@ import { Layout, Toast } from "asc-web-components"; import { logout } from "../../store/auth/actions"; import { withTranslation, I18nextProvider } from 'react-i18next'; import i18n from "./i18n"; +import isEqual from "lodash/isEqual"; class PureStudioLayout extends React.Component { - shouldComponentUpdate(nextProps) { - if(this.props.hasChanges !== nextProps.hasChanges) { - return true; - } - - return false; - } + shouldComponentUpdate(nextProps, nextState) { + return !isEqual(this.props, nextProps) || !isEqual(this.state, nextState); + } onProfileClick = () => { window.location.href = "/products/people/view/@self"; diff --git a/web/ASC.Web.Components/src/components/layout/index.js b/web/ASC.Web.Components/src/components/layout/index.js index 72dd8efdad..e072f8bd9a 100644 --- a/web/ASC.Web.Components/src/components/layout/index.js +++ b/web/ASC.Web.Components/src/components/layout/index.js @@ -36,7 +36,8 @@ class Layout extends React.Component { hash += props.currentModuleId; } if (props.currentUser) { - hash += props.currentUser.id; + const { id, displayName, email, avatarSmall } = props.currentUser; + hash += id + displayName + email + avatarSmall; } if (props.availableModules) { for (let i = 0, l = props.availableModules.length; i < l; i++) { diff --git a/web/ASC.Web.Components/src/components/layout/sub-components/profile-actions.js b/web/ASC.Web.Components/src/components/layout/sub-components/profile-actions.js index defbf81b58..dacb545091 100644 --- a/web/ASC.Web.Components/src/components/layout/sub-components/profile-actions.js +++ b/web/ASC.Web.Components/src/components/layout/sub-components/profile-actions.js @@ -42,6 +42,11 @@ class ProfileActions extends React.PureComponent { } componentDidUpdate(prevProps, prevState) { + + if (this.props.user !== prevProps.user) { + this.setState({ user: this.props.user }) + } + if (this.props.opened !== prevProps.opened) { this.toggle(this.props.opened); }