From 5bd7a3b29c95b59be53cb8e09714bcb203356e68 Mon Sep 17 00:00:00 2001 From: Alexey Kostenko Date: Thu, 15 Oct 2020 13:49:55 +0300 Subject: [PATCH] Web: People: Fix loading main People page, after switching from profile --- products/ASC.People/Client/src/App.js | 6 ++++-- .../src/components/pages/Home/Section/Body/index.js | 13 ++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/products/ASC.People/Client/src/App.js b/products/ASC.People/Client/src/App.js index 18690d8059..19a47057b3 100644 --- a/products/ASC.People/Client/src/App.js +++ b/products/ASC.People/Client/src/App.js @@ -21,7 +21,8 @@ import { NavMenu, Main, toastr, -} from "asc-web-common";import { getFilterByLocation } from "./helpers/converters"; +} from "asc-web-common"; +import { getFilterByLocation } from "./helpers/converters"; import { fetchGroups, fetchPeople } from "./store/people/actions"; import config from "../package.json"; @@ -55,7 +56,8 @@ class App extends React.Component { fetchGroups, fetchPeople, finalize, - setIsLoaded, } = this.props; + setIsLoaded, + } = this.props; setModuleInfo(); diff --git a/products/ASC.People/Client/src/components/pages/Home/Section/Body/index.js b/products/ASC.People/Client/src/components/pages/Home/Section/Body/index.js index 4b7869f413..31cae6d601 100644 --- a/products/ASC.People/Client/src/components/pages/Home/Section/Body/index.js +++ b/products/ASC.People/Client/src/components/pages/Home/Section/Body/index.js @@ -39,6 +39,7 @@ const i18n = createI18N({ }); const { isArrayEqual } = utils.array; const { getSettings } = store.auth.selectors; +const { setIsLoaded } = store.auth.actions; const { resendUserInvites } = api.people; const { EmployeeStatus } = constants; @@ -59,11 +60,16 @@ class SectionBodyContent extends React.PureComponent { } componentDidMount() { - const { isLoaded, fetchPeople, filter } = this.props; - + const { isLoaded, fetchPeople, filter, setIsLoaded, peopleList } = this.props; if (!isLoaded) return; - fetchPeople(filter).catch((error) => toastr.error(error)); + if(peopleList.length <= 0) setIsLoaded(); + fetchPeople(filter) + .then(() => isLoaded && setIsLoaded(true)) + .catch((error) => { + isLoaded && setIsLoaded(true) + toastr.error(error) + }); } findUserById = (id) => this.props.peopleList.find((man) => man.id === id); @@ -493,4 +499,5 @@ export default connect(mapStateToProps, { resetFilter, fetchPeople, selectGroup, + setIsLoaded, })(withRouter(withTranslation()(SectionBodyContent)));