Web: People: Fix loading main People page, after switching from profile

This commit is contained in:
Alexey Kostenko 2020-10-15 13:49:55 +03:00
parent d7d2a94181
commit 5bd7a3b29c
2 changed files with 14 additions and 5 deletions

View File

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

View File

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