Skip to content

Commit

Permalink
move to const
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed Mar 1, 2024
1 parent f353a3e commit c186109
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3332,6 +3332,10 @@ const CONST = {
SESSION_STORAGE_KEYS: {
INITIAL_URL: 'INITIAL_URL',
},

AUTH_TOKEN_TYPE: {
ANONYMOUS: 'anonymousAccount',
},
} as const;

type Country = keyof typeof CONST.ALL_COUNTRIES;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ Onyx.connect({

currentUserEmail = value.email;
currentUserAccountID = value.accountID;
isAnonymousUser = value.authTokenType === 'anonymousAccount';
isAnonymousUser = value.authTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS;
currentUserPrivateDomain = isEmailPublicDomain(currentUserEmail ?? '') ? '' : Str.extractEmailDomain(currentUserEmail ?? '');
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function signOut() {
* Checks if the account is an anonymous account.
*/
function isAnonymousUser(): boolean {
return sessionAuthTokenType === 'anonymousAccount';
return sessionAuthTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS;
}

function signOutAndRedirectToSignIn(shouldReplaceCurrentScreen?: boolean) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function ReportActionsView(props) {
}, [props.network, isReportFullyVisible]);

useEffect(() => {
const wasLoginChangedDetected = prevAuthTokenType === 'anonymousAccount' && !props.session.authTokenType;
const wasLoginChangedDetected = prevAuthTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS && !props.session.authTokenType;
if (wasLoginChangedDetected && didUserLogInDuringSession() && isUserCreatedPolicyRoom(props.report)) {
if (isReportFullyVisible) {
openReportIfNecessary();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function ReportFooter(props) {
const {isOffline} = useNetwork();
const chatFooterStyles = {...styles.chatFooter, minHeight: !isOffline ? CONST.CHAT_FOOTER_MIN_HEIGHT : 0};
const isArchivedRoom = ReportUtils.isArchivedRoom(props.report);
const isAnonymousUser = props.session.authTokenType === 'anonymousAccount';
const isAnonymousUser = props.session.authTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS;

const isSmallSizeLayout = props.windowWidth - (props.isSmallScreenWidth ? 0 : variables.sideBarWidth) < variables.anonymousReportFooterBreakpoint;
const hideComposer = !ReportUtils.canUserPerformWriteAction(props.report);
Expand Down
3 changes: 2 additions & 1 deletion src/pages/signin/SignInModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ScreenWrapper from '@components/ScreenWrapper';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import SCREENS from '@src/SCREENS';
import type {Session} from '@src/types/onyx';
Expand All @@ -22,7 +23,7 @@ function SignInModal({session}: SignInModalProps) {
const StyleUtils = useStyleUtils();

useEffect(() => {
const isAnonymousUser = session?.authTokenType === 'anonymousAccount';
const isAnonymousUser = session?.authTokenType === CONST.AUTH_TOKEN_TYPE.ANONYMOUS;
if (!isAnonymousUser) {
// Signing in RHP is only for anonymous users
Navigation.isNavigationReady().then(() => Navigation.dismissModal());
Expand Down

0 comments on commit c186109

Please sign in to comment.