@@ -15,27 +15,29 @@ import SidebarLinksData from '@pages/home/sidebar/SidebarLinksData';
15
15
import Timing from '@userActions/Timing' ;
16
16
import CONST from '@src/CONST' ;
17
17
import ONYXKEYS from '@src/ONYXKEYS' ;
18
+ import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue' ;
18
19
19
20
function BaseSidebarScreen ( ) {
20
21
const styles = useThemeStyles ( ) ;
21
22
const activeWorkspaceID = useActiveWorkspaceFromNavigationState ( ) ;
22
23
const { translate} = useLocalize ( ) ;
23
24
const { shouldUseNarrowLayout} = useResponsiveLayout ( ) ;
24
- const [ activeWorkspace ] = useOnyx ( `${ ONYXKEYS . COLLECTION . POLICY } ${ activeWorkspaceID ?? CONST . DEFAULT_NUMBER_ID } ` ) ;
25
+ const [ activeWorkspace , activeWorkspaceResult ] = useOnyx ( `${ ONYXKEYS . COLLECTION . POLICY } ${ activeWorkspaceID ?? CONST . DEFAULT_NUMBER_ID } ` ) ;
26
+ const isLoading = isLoadingOnyxValue ( activeWorkspaceResult ) ;
25
27
26
28
useEffect ( ( ) => {
27
29
Performance . markStart ( CONST . TIMING . SIDEBAR_LOADED ) ;
28
30
Timing . start ( CONST . TIMING . SIDEBAR_LOADED ) ;
29
31
} , [ ] ) ;
30
32
31
33
useEffect ( ( ) => {
32
- if ( ! ! activeWorkspace || activeWorkspaceID === undefined ) {
34
+ if ( ! ! activeWorkspace || activeWorkspaceID === undefined || isLoading ) {
33
35
return ;
34
36
}
35
37
36
38
Navigation . navigateWithSwitchPolicyID ( { policyID : undefined } ) ;
37
39
updateLastAccessedWorkspace ( undefined ) ;
38
- } , [ activeWorkspace , activeWorkspaceID ] ) ;
40
+ } , [ activeWorkspace , activeWorkspaceID , isLoading ] ) ;
39
41
40
42
const shouldDisplaySearch = shouldUseNarrowLayout ;
41
43
0 commit comments