Skip to content

Commit 4971e09

Browse files
fix: remove unnecessary requests for home/config/elements
1 parent e5bc573 commit 4971e09

File tree

2 files changed

+4
-33
lines changed

2 files changed

+4
-33
lines changed

client/packages/lowcoder/src/app.tsx

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@ import { CodeEditorTooltipContainer } from "base/codeEditor/codeEditor";
3939
import { ProductLoading } from "components/ProductLoading";
4040
import { language, trans } from "i18n";
4141
import { loadComps } from "comps";
42-
import { fetchHomeData } from "redux/reduxActions/applicationActions";
4342
import { initApp } from "util/commonUtils";
4443
import ApplicationHome from "./pages/ApplicationV2";
4544
import { favicon } from "@lowcoder-ee/assets/images";
4645
import { hasQueryParam } from "util/urlUtils";
4746
import { isFetchUserFinished } from "redux/selectors/usersSelectors";
4847
import { SystemWarning } from "./components/SystemWarning";
49-
import { getBrandingConfig, getSystemConfigFetching } from "./redux/selectors/configSelectors";
48+
import { getBrandingConfig } from "./redux/selectors/configSelectors";
5049
import { buildMaterialPreviewURL } from "./util/materialUtils";
5150
import GlobalInstances from 'components/GlobalInstances';
5251

@@ -71,35 +70,22 @@ const Wrapper = (props: { children: React.ReactNode }) => (
7170

7271
type AppIndexProps = {
7372
isFetchUserFinished: boolean;
74-
isFetchHomeFinished: boolean;
75-
// isFetchingConfig: boolean;
7673
currentOrgId?: string;
7774
orgDev: boolean;
7875
defaultHomePage: string | null | undefined;
7976
fetchConfig: (orgId?: string) => void;
8077
getCurrentUser: () => void;
81-
fetchHome: () => void;
8278
favicon: string;
8379
brandName: string;
8480
};
8581

8682
class AppIndex extends React.Component<AppIndexProps, any> {
8783
componentDidMount() {
8884
this.props.getCurrentUser();
89-
const { pathname } = history.location;
90-
91-
this.props.fetchConfig(this.props.currentOrgId);
92-
93-
if (pathname === BASE_URL) {
94-
this.props.fetchHome();
95-
}
9685
}
9786

9887
componentDidUpdate(prevProps: AppIndexProps) {
99-
if (history.location.pathname === BASE_URL) {
100-
this.props.fetchHome();
101-
}
102-
if(prevProps.currentOrgId !== this.props.currentOrgId) {
88+
if(prevProps.currentOrgId !== this.props.currentOrgId && this.props.currentOrgId !== '') {
10389
this.props.fetchConfig(this.props.currentOrgId);
10490
}
10591
}
@@ -108,11 +94,7 @@ class AppIndex extends React.Component<AppIndexProps, any> {
10894
const isTemplate = hasQueryParam("template");
10995
const pathname = history.location.pathname;
11096
// make sure all users in this app have checked login info
111-
if (
112-
!this.props.isFetchUserFinished ||
113-
// this.props.isFetchingConfig ||
114-
(pathname === BASE_URL && !this.props.isFetchHomeFinished)
115-
) {
97+
if (!this.props.isFetchUserFinished) {
11698
const hideLoadingHeader = isTemplate || isAuthUnRequired(pathname);
11799
return <ProductLoading hideHeader={hideLoadingHeader} />;
118100
}
@@ -185,11 +167,9 @@ class AppIndex extends React.Component<AppIndexProps, any> {
185167

186168
const mapStateToProps = (state: AppState) => ({
187169
isFetchUserFinished: isFetchUserFinished(state),
188-
// isFetchingConfig: getSystemConfigFetching(state),
189170
orgDev: state.ui.users.user.orgDev,
190171
currentOrgId: state.ui.users.user.currentOrgId,
191172
defaultHomePage: state.ui.application.homeOrg?.commonSettings.defaultHomePage,
192-
isFetchHomeFinished: state.ui.application.loadingStatus.fetchHomeDataFinished,
193173
favicon: getBrandingConfig(state)?.favicon
194174
? buildMaterialPreviewURL(getBrandingConfig(state)?.favicon!)
195175
: favicon,
@@ -201,7 +181,6 @@ const mapDispatchToProps = (dispatch: any) => ({
201181
dispatch(fetchUserAction());
202182
},
203183
fetchConfig: (orgId?: string) => dispatch(fetchConfigAction(orgId)),
204-
fetchHome: () => dispatch(fetchHomeData({})),
205184
});
206185

207186
const AppIndexWithProps = connect(mapStateToProps, mapDispatchToProps)(AppIndex);

client/packages/lowcoder/src/pages/ApplicationV2/HomeView.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1-
import { useDispatch, useSelector } from "react-redux";
1+
import { useSelector } from "react-redux";
22
import { HomeLayout } from "./HomeLayout";
3-
import { useEffect } from "react";
4-
import { fetchFolderElements } from "../../redux/reduxActions/folderActions";
53
import { getUser } from "../../redux/selectors/usersSelectors";
64
import { folderElementsSelector } from "../../redux/selectors/folderSelector";
75

86
export function HomeView() {
9-
const dispatch = useDispatch();
10-
117
const elements = useSelector(folderElementsSelector)[""];
128
const user = useSelector(getUser);
139

14-
useEffect(() => {
15-
dispatch(fetchFolderElements({}));
16-
}, []);
17-
1810
if (!user.currentOrgId) {
1911
return null;
2012
}

0 commit comments

Comments
 (0)