Skip to content

Commit

Permalink
Merge pull request #42702 from bernhardoj/fix/42639-header-missing-br…
Browse files Browse the repository at this point in the history
…iefly

Fix header in Home page is missing briefly when app is launched
  • Loading branch information
luacmartins authored May 28, 2024
2 parents a1868c8 + 73ea407 commit e9698b5
Showing 1 changed file with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import Breadcrumbs from '@components/Breadcrumbs';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
Expand All @@ -17,20 +16,15 @@ import * as Session from '@userActions/Session';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Policy, Session as SessionType} from '@src/types/onyx';

type TopBarOnyxProps = {
policy: OnyxEntry<Policy>;
session: OnyxEntry<Pick<SessionType, 'authTokenType'>>;
};
type TopBarProps = {breadcrumbLabel: string; activeWorkspaceID?: string; shouldDisplaySearch?: boolean};

// eslint-disable-next-line react/no-unused-prop-types
type TopBarProps = {breadcrumbLabel: string; activeWorkspaceID?: string; shouldDisplaySearch?: boolean} & TopBarOnyxProps;

function TopBar({policy, session, breadcrumbLabel, shouldDisplaySearch = true}: TopBarProps) {
function TopBar({breadcrumbLabel, activeWorkspaceID, shouldDisplaySearch = true}: TopBarProps) {
const styles = useThemeStyles();
const theme = useTheme();
const {translate} = useLocalize();
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activeWorkspaceID}`);
const [session] = useOnyx(ONYXKEYS.SESSION, {selector: (sessionValue) => sessionValue && {authTokenType: sessionValue.authTokenType}});
const isAnonymousUser = Session.isAnonymousUser(session);

const headerBreadcrumb = policy?.name
Expand Down Expand Up @@ -84,12 +78,4 @@ function TopBar({policy, session, breadcrumbLabel, shouldDisplaySearch = true}:

TopBar.displayName = 'TopBar';

export default withOnyx<TopBarProps, TopBarOnyxProps>({
policy: {
key: ({activeWorkspaceID}) => `${ONYXKEYS.COLLECTION.POLICY}${activeWorkspaceID}`,
},
session: {
key: ONYXKEYS.SESSION,
selector: (session) => session && {authTokenType: session.authTokenType},
},
})(TopBar);
export default TopBar;

0 comments on commit e9698b5

Please sign in to comment.