@@ -55,6 +55,7 @@ import { getBrandingConfig } from "./redux/selectors/configSelectors";
55
55
import { buildMaterialPreviewURL } from "./util/materialUtils" ;
56
56
import GlobalInstances from 'components/GlobalInstances' ;
57
57
import posthog from 'posthog-js'
58
+ import { fetchHomeData } from "./redux/reduxActions/applicationActions" ;
58
59
59
60
const LazyUserAuthComp = React . lazy ( ( ) => import ( "pages/userAuth" ) ) ;
60
61
const LazyInviteLanding = React . lazy ( ( ) => import ( "pages/common/inviteLanding" ) ) ;
@@ -82,9 +83,12 @@ type AppIndexProps = {
82
83
isFetchUserFinished : boolean ;
83
84
getIsCommonSettingFetched : boolean ;
84
85
currentOrgId ?: string ;
86
+ currentUserId : string ;
85
87
orgDev : boolean ;
86
88
defaultHomePage : string | null | undefined ;
89
+ fetchHomeDataFinished : boolean ;
87
90
fetchConfig : ( orgId ?: string ) => void ;
91
+ fetchHomeData : ( ) => void ;
88
92
getCurrentUser : ( ) => void ;
89
93
favicon : string ;
90
94
brandName : string ;
@@ -94,6 +98,7 @@ type AppIndexProps = {
94
98
class AppIndex extends React . Component < AppIndexProps , any > {
95
99
componentDidMount ( ) {
96
100
this . props . getCurrentUser ( ) ;
101
+ this . props . fetchHomeData ( ) ;
97
102
}
98
103
99
104
componentDidUpdate ( prevProps : AppIndexProps ) {
@@ -102,6 +107,7 @@ class AppIndex extends React.Component<AppIndexProps, any> {
102
107
this . props . currentOrgId !== ''
103
108
) {
104
109
this . props . fetchConfig ( this . props . currentOrgId ) ;
110
+ this . props . fetchHomeData ( ) ;
105
111
}
106
112
}
107
113
render ( ) {
@@ -117,16 +123,14 @@ class AppIndex extends React.Component<AppIndexProps, any> {
117
123
}
118
124
119
125
// make sure all users in this app have checked login info
120
- if ( ! this . props . isFetchUserFinished ) {
126
+ if ( ! this . props . isFetchUserFinished || ( this . props . currentUserId && ! this . props . fetchHomeDataFinished ) ) {
121
127
const hideLoadingHeader = isTemplate || isAuthUnRequired ( pathname ) ;
122
128
return < ProductLoading hideHeader = { hideLoadingHeader } /> ;
123
129
}
124
130
125
131
// persisting the language in local storage
126
132
localStorage . setItem ( 'lowcoder_uiLanguage' , this . props . uiLanguage ) ;
127
133
128
- console . log ( 'Props: ' , this . props ) ;
129
-
130
134
return (
131
135
< Wrapper language = { this . props . uiLanguage } >
132
136
< Helmet >
@@ -276,8 +280,8 @@ class AppIndex extends React.Component<AppIndexProps, any> {
276
280
< SystemWarning />
277
281
< Router history = { history } >
278
282
< Switch >
279
- { this . props . isFetchUserFinished && ! this . props . orgDev ? (
280
- this . props . getIsCommonSettingFetched && this . props . defaultHomePage !== undefined ? (
283
+ { this . props . isFetchUserFinished && this . props . defaultHomePage ? (
284
+ ! this . props . orgDev ? (
281
285
< Redirect exact from = { BASE_URL } to = { APPLICATION_VIEW_URL ( this . props . defaultHomePage || "" , "view" ) } />
282
286
) : (
283
287
< Redirect exact from = { BASE_URL } to = { ORG_HOME_URL } />
@@ -374,8 +378,10 @@ const mapStateToProps = (state: AppState) => ({
374
378
isFetchUserFinished : isFetchUserFinished ( state ) ,
375
379
getIsCommonSettingFetched : getIsCommonSettingFetched ( state ) ,
376
380
orgDev : state . ui . users . user . orgDev ,
381
+ currentUserId : state . ui . users . currentUser . id ,
377
382
currentOrgId : state . ui . users . user . currentOrgId ,
378
383
defaultHomePage : state . ui . application . homeOrg ?. commonSettings . defaultHomePage ,
384
+ fetchHomeDataFinished : Boolean ( state . ui . application . homeOrg ?. commonSettings ) ,
379
385
favicon : getBrandingConfig ( state ) ?. favicon
380
386
? buildMaterialPreviewURL ( getBrandingConfig ( state ) ?. favicon ! )
381
387
: favicon ,
@@ -388,6 +394,7 @@ const mapDispatchToProps = (dispatch: any) => ({
388
394
dispatch ( fetchUserAction ( ) ) ;
389
395
} ,
390
396
fetchConfig : ( orgId ?: string ) => dispatch ( fetchConfigAction ( orgId ) ) ,
397
+ fetchHomeData : ( ) => dispatch ( fetchHomeData ( { } ) )
391
398
} ) ;
392
399
393
400
const AppIndexWithProps = connect ( mapStateToProps , mapDispatchToProps ) ( AppIndex ) ;
0 commit comments