Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sign in button remains when login new user via public room #39608

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ import * as Session from '@userActions/Session';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Policy} from '@src/types/onyx';
import type {Policy, Session as SessionType} from '@src/types/onyx';

type TopBarOnyxProps = {
policy: OnyxEntry<Policy>;
session: OnyxEntry<Pick<SessionType, 'authTokenType'>>;
};

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

function TopBar({policy}: TopBarProps) {
function TopBar({policy, session}: TopBarProps) {
const styles = useThemeStyles();
const theme = useTheme();
const {translate} = useLocalize();
const isAnonymousUser = Session.isAnonymousUser(session);

const headerBreadcrumb = policy?.name
? {type: CONST.BREADCRUMB_TYPE.STRONG, text: policy.name}
Expand Down Expand Up @@ -57,7 +59,7 @@ function TopBar({policy}: TopBarProps) {
/>
</View>
</View>
{Session.isAnonymousUser() ? (
{isAnonymousUser ? (
<SignInButton />
) : (
<Tooltip text={translate('common.search')}>
Expand All @@ -84,4 +86,8 @@ export default withOnyx<TopBarProps, TopBarOnyxProps>({
policy: {
key: ({activeWorkspaceID}) => `${ONYXKEYS.COLLECTION.POLICY}${activeWorkspaceID}`,
},
session: {
key: ONYXKEYS.SESSION,
selector: (session) => session && {authTokenType: session.authTokenType},
},
})(TopBar);
6 changes: 3 additions & 3 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import throttle from 'lodash/throttle';
import type {ChannelAuthorizationData} from 'pusher-js/types/src/core/auth/options';
import type {ChannelAuthorizationCallback} from 'pusher-js/with-encryption';
import {InteractionManager, Linking, NativeModules} from 'react-native';
import type {OnyxUpdate} from 'react-native-onyx';
import type {OnyxEntry, OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import * as PersistedRequests from '@libs/actions/PersistedRequests';
Expand Down Expand Up @@ -175,8 +175,8 @@ function signOut() {
/**
* Checks if the account is an anonymous account.
*/
function isAnonymousUser(): boolean {
return session.authTokenType === CONST.AUTH_TOKEN_TYPES.ANONYMOUS;
function isAnonymousUser(sessionParam?: OnyxEntry<Session>): boolean {
return (sessionParam?.authTokenType ?? session.authTokenType) === CONST.AUTH_TOKEN_TYPES.ANONYMOUS;
}

function hasStashedSession(): boolean {
Expand Down
Loading