Web: fixed loading people/my, fixed Loaders.ProfileView, deleted unnecessary code

This commit is contained in:
Artem Tarasov 2021-06-11 16:57:17 +03:00
parent f181a491fb
commit d44f1bee0f
3 changed files with 28 additions and 19 deletions

View File

@ -179,9 +179,11 @@ const ProfileViewLoader = ({ id, className, style, isEdit, ...rest }) => {
/>
</StyledBox1>
<RectangleLoader
className="rectangle-loader"
title={title}
width="100%"
height="80"
style={{ maxWidth: "420px" }}
borderRadius={borderRadius}
backgroundColor={backgroundColor}
foregroundColor={foregroundColor}

View File

@ -19,9 +19,19 @@ import EditBodyContent from "../ProfileAction/Section/Body";
class My extends React.Component {
componentDidMount() {
const { fetchProfile, profile, location, t, setDocumentTitle } = this.props;
const {
fetchProfile,
profile,
location,
t,
setDocumentTitle,
setLoadedProfile,
setIsLoading,
setFirstLoad,
} = this.props;
setDocumentTitle(t("Common:Profile"));
setFirstLoad(false);
this.documentElement = document.getElementsByClassName("hidingHeader");
const queryString = ((location && location.search) || "").slice(1);
@ -35,7 +45,12 @@ class My extends React.Component {
toastr.success(t("ChangeEmailSuccess"));
}
if (!profile) {
fetchProfile("@self");
setIsLoading(true);
setLoadedProfile(false);
fetchProfile("@self").finally(() => {
setIsLoading(false);
setLoadedProfile(true);
});
}
if (!profile && this.documentElement) {
@ -59,26 +74,18 @@ class My extends React.Component {
return (
<PageLayout withBodyAutoFocus>
<PageLayout.SectionHeader>
{profile && tReady ? (
isEdit ? (
<EditHeaderContent isMy={true} />
) : (
<ViewHeaderContent isMy={true} />
)
{isEdit ? (
<EditHeaderContent isMy={true} tReady={tReady} />
) : (
<Loaders.SectionHeader />
<ViewHeaderContent isMy={true} tReady={tReady} />
)}
</PageLayout.SectionHeader>
<PageLayout.SectionBody>
{profile && tReady ? (
isEdit ? (
<EditBodyContent isMy={true} />
) : (
<ViewBodyContent isMy={true} />
)
{isEdit ? (
<EditBodyContent isMy={true} tReady={tReady} />
) : (
<Loaders.ProfileView />
<ViewBodyContent isMy={true} tReady={tReady} />
)}
</PageLayout.SectionBody>
</PageLayout>
@ -101,6 +108,9 @@ const MyProfile = withRouter(
resetProfile: peopleStore.targetUserStore.resetTargetUser,
fetchProfile: peopleStore.targetUserStore.getTargetUser,
profile: peopleStore.targetUserStore.targetUser,
setLoadedProfile: peopleStore.loadingStore.setLoadedProfile,
setIsLoading: peopleStore.loadingStore.setIsLoading,
setFirstLoad: peopleStore.loadingStore.setFirstLoad,
}))(withTranslation(["Profile", "ProfileAction"])(observer(My)))
);

View File

@ -83,7 +83,6 @@ const SectionHeaderContent = (props) => {
}
if (!isEditTargetUser && (!profile || !document.referrer)) {
console.log("here1");
setFilterAndReset(filter);
const urlFilter = filter.toUrlParams();
return history.push(
@ -91,8 +90,6 @@ const SectionHeaderContent = (props) => {
);
}
console.log("here2");
history.push(
combineUrl(
AppServerConfig.proxyURL,