Skip to content
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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/components/BookCallButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';

import {openExternalLink} from '@libs/actions/Link';
import {callFunctionIfActionIsAllowed} from '@libs/actions/Session';
import {callIfAuthenticated} from '@libs/actions/Session';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -44,7 +44,7 @@ function BookCallButton({calendarLink, avatarAccountID, isNested = false, style}
const label = translate('videoChatButtonAndMenu.tooltip');

const commonProps = {
onPress: callFunctionIfActionIsAllowed(() => openExternalLink(calendarLink), false, session),
onPress: callIfAuthenticated(() => openExternalLink(calendarLink), session),
sentryLabel: CONST.SENTRY_LABEL.ACCOUNT_MANAGER_BOOK_CALL.BUTTON,
accessibilityLabel: label,
isNested,
Expand Down
6 changes: 3 additions & 3 deletions src/components/ChronosTimerHeaderButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {startOrStopChronosTimer} from '@libs/actions/Chronos';
import Navigation from '@libs/Navigation/Navigation';
import {canWriteInReport} from '@libs/ReportUtils';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -59,7 +59,7 @@ function ChronosTimerHeaderButton({report}: ChronosTimerHeaderButtonProps) {
value: 'timer' as const,
text: timerStartTime ? translate('chronos.stopTimer', formatElapsedTime(timerStartTime)) : translate('chronos.startTimer'),
onSelected: () => {
callFunctionIfActionIsAllowed(toggleChronosTimer, false, session)();
callIfAuthenticated(toggleChronosTimer, session)();
},
},
{
Expand All @@ -81,7 +81,7 @@ function ChronosTimerHeaderButton({report}: ChronosTimerHeaderButtonProps) {
<ButtonWithDropdownMenu<ChronosAction>
variant={!timerStartTime ? CONST.BUTTON_VARIANT.SUCCESS : undefined}
onPress={() => {
callFunctionIfActionIsAllowed(toggleChronosTimer, false, session)();
callIfAuthenticated(toggleChronosTimer, session)();
}}
options={options}
wrapperStyle={styles.flex1}
Expand Down
4 changes: 2 additions & 2 deletions src/components/CountryPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import useOnyx from '@hooks/useOnyx';

import type {Option} from '@libs/searchOptions';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
Expand Down Expand Up @@ -50,7 +50,7 @@ function CountryPicker({value, errorText, onInputChange = () => {}, label, disab
return (
<>
<MenuItem.Root
onPress={callFunctionIfActionIsAllowed(() => setIsPickerVisible(true), false, session)}
onPress={callIfAuthenticated(() => setIsPickerVisible(true), session)}
isDisabled={disabled}
sentryLabel={CONST.SENTRY_LABEL.COUNTRY_PICKER.OPEN}
>
Expand Down
4 changes: 2 additions & 2 deletions src/components/CurrencyPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useThemeStyles from '@hooks/useThemeStyles';

import Navigation from '@libs/Navigation/Navigation';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -89,7 +89,7 @@ function CurrencyPicker({
return (
<>
<MenuItem.Root
onPress={callFunctionIfActionIsAllowed(() => setIsPickerVisible(true), false, session)}
onPress={callIfAuthenticated(() => setIsPickerVisible(true), session)}
isDisabled={disabled}
accessibilityLabel={accessibilityLabel ? [accessibilityLabel, value ? `${value} - ${getCurrencySymbol(value)}` : undefined].filter(Boolean).join(', ') : undefined}
>
Expand Down
4 changes: 2 additions & 2 deletions src/components/ListField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import Accessibility from '@libs/Accessibility';
import {getLetterAvatarURLForName} from '@libs/UserAvatarUtils';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -182,7 +182,7 @@ function ListField({rows, addTitle, addDescription, canAddMore = true, errorText
{canAddMore && (
<MenuItem.Root
ref={addRowRef}
onPress={callFunctionIfActionIsAllowed(onAdd, false, session)}
onPress={callIfAuthenticated(onAdd, session)}
>
<AddRowErrorAnnouncement errorText={errorText} />
<MenuItem.Row>
Expand Down
4 changes: 2 additions & 2 deletions src/components/MenuItem/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import {showContextMenu} from '@pages/inbox/report/ContextMenu/ReportActionConte
import {fontScale, lineHeightScale} from '@styles/typography';
import variables from '@styles/variables';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -869,7 +869,7 @@ function MenuItem({
>
{(isHovered) => (
<PressableWithSecondaryInteraction
onPress={shouldCheckActionAllowedOnPress ? callFunctionIfActionIsAllowed(onPressAction, isAnonymousAction, session) : onPressAction}
onPress={shouldCheckActionAllowedOnPress && !isAnonymousAction ? callIfAuthenticated(onPressAction, session) : onPressAction}
onMouseDown={(event) => {
markMouseDownOnCopyableText(event?.target, isTitleSelectable);
}}
Expand Down
4 changes: 2 additions & 2 deletions src/components/MenuItem/presets/MenuItemAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import MenuItemIcon from '@components/MenuItem/leaves/leading/MenuItemIcon';

import useOnyx from '@hooks/useOnyx';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import ONYXKEYS from '@src/ONYXKEYS';
import type IconAsset from '@src/types/utils/IconAsset';
Expand Down Expand Up @@ -42,7 +42,7 @@ function MenuItemAction({title, icon, onPress, isDisabled = false, sentryLabel,
const [session] = useOnyx(ONYXKEYS.SESSION, {selector: authTokenTypeSelector});
return (
<MenuItemRoot
onPress={callFunctionIfActionIsAllowed(onPress, false, session)}
onPress={callIfAuthenticated(onPress, session)}
isDisabled={isDisabled}
sentryLabel={sentryLabel}
testID={testID}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import useOnyx from '@hooks/useOnyx';
import type {ForwardedFSClassProps} from '@libs/Fullstory/types';
import type {AvatarSource} from '@libs/UserAvatarUtils';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import ONYXKEYS from '@src/ONYXKEYS';
import type WithSentryLabel from '@src/types/utils/SentryLabel';
Expand Down Expand Up @@ -54,7 +54,7 @@ function MenuItemAvatarNavigation({title, description, accountID, avatarSource,
const [session] = useOnyx(ONYXKEYS.SESSION, {selector: authTokenTypeSelector});
return (
<MenuItemRoot
onPress={callFunctionIfActionIsAllowed(onPress, false, session)}
onPress={callIfAuthenticated(onPress, session)}
isDisabled={isDisabled}
sentryLabel={sentryLabel}
testID={testID}
Expand Down
4 changes: 2 additions & 2 deletions src/components/MenuItem/presets/MenuItemField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import useOnyx from '@hooks/useOnyx';
import type {ForwardedFSClassProps} from '@libs/Fullstory/types';
import hasRenderableChildren from '@libs/hasRenderableChildren';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import ONYXKEYS from '@src/ONYXKEYS';

Expand Down Expand Up @@ -111,7 +111,7 @@ function MenuItemFieldPreset({
const [session] = useOnyx(ONYXKEYS.SESSION, {selector: authTokenTypeSelector});
return (
<MenuItemRoot
onPress={onPress ? callFunctionIfActionIsAllowed(onPress, false, session) : undefined}
onPress={onPress ? callIfAuthenticated(onPress, session) : undefined}
isDisabled={isDisabled}
sentryLabel={sentryLabel}
testID={testID}
Expand Down
4 changes: 2 additions & 2 deletions src/components/MenuItem/presets/MenuItemFieldHTML.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useOnyx from '@hooks/useOnyx';

import hasRenderableChildren from '@libs/hasRenderableChildren';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import ONYXKEYS from '@src/ONYXKEYS';

Expand Down Expand Up @@ -40,7 +40,7 @@ function MenuItemFieldHTML({name, value, characterLimit, children, onPress, isDi
const [session] = useOnyx(ONYXKEYS.SESSION, {selector: authTokenTypeSelector});
return (
<MenuItemRoot
onPress={onPress ? callFunctionIfActionIsAllowed(onPress, false, session) : undefined}
onPress={onPress ? callIfAuthenticated(onPress, session) : undefined}
isDisabled={isDisabled}
sentryLabel={sentryLabel}
testID={testID}
Expand Down
4 changes: 2 additions & 2 deletions src/components/MenuItem/presets/MenuItemNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MenuItemChevron from '@components/MenuItem/leaves/trailing/icons/MenuItem

import useOnyx from '@hooks/useOnyx';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import ONYXKEYS from '@src/ONYXKEYS';
import type IconAsset from '@src/types/utils/IconAsset';
Expand Down Expand Up @@ -44,7 +44,7 @@ function MenuItemNavigation({title, icon, onPress, isDisabled = false, sentryLab
const [session] = useOnyx(ONYXKEYS.SESSION, {selector: authTokenTypeSelector});
return (
<MenuItemRoot
onPress={callFunctionIfActionIsAllowed(onPress, false, session)}
onPress={callIfAuthenticated(onPress, session)}
isDisabled={isDisabled}
sentryLabel={sentryLabel}
testID={testID}
Expand Down
4 changes: 2 additions & 2 deletions src/components/MenuItem/presets/MenuItemWithLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import MenuItemLabel from '@components/MenuItem/leaves/content/MenuItemLabel';
import useOnyx from '@hooks/useOnyx';
import useThemeStyles from '@hooks/useThemeStyles';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import ONYXKEYS from '@src/ONYXKEYS';

Expand All @@ -32,7 +32,7 @@ function MenuItemWithLabel({label, onPress, isDisabled = false, sentryLabel, tes
<MenuItemLabel>{label}</MenuItemLabel>
</View>
<MenuItemRoot
onPress={onPress ? callFunctionIfActionIsAllowed(onPress, false, session) : undefined}
onPress={onPress ? callIfAuthenticated(onPress, session) : undefined}
isDisabled={isDisabled}
sentryLabel={sentryLabel}
testID={testID}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/crea
import Navigation from '@libs/Navigation/Navigation';
import {getAttendeesListDisplayString} from '@libs/TransactionUtils';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import CONST from '@src/CONST';
import type {IOUAction, IOUType} from '@src/CONST';
Expand Down Expand Up @@ -120,7 +120,7 @@ function AttendeeField({formattedAmountPerAttendee, isReadOnly, transactionID, a

return (
<MenuItem.Root
onPress={isReadOnly ? undefined : callFunctionIfActionIsAllowed(openAttendeePage, false, session)}
onPress={isReadOnly ? undefined : callIfAuthenticated(openAttendeePage, session)}
accessibilityLabel={attendeesAccessibilityLabel}
sentryLabel={CONST.SENTRY_LABEL.REQUEST_CONFIRMATION_LIST.ATTENDEES_FIELD}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import DistanceRequestUtils from '@libs/DistanceRequestUtils';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
import Navigation from '@libs/Navigation/Navigation';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -79,7 +79,7 @@ function DistanceField({hasRoute, distance, unit, customUnit}: DistanceFieldProp

return (
<MenuItem.Root
onPress={isDistanceInteractive ? callFunctionIfActionIsAllowed(openDistancePage, false, session) : undefined}
onPress={isDistanceInteractive ? callIfAuthenticated(openDistancePage, session) : undefined}
isDisabled={didConfirm}
sentryLabel={CONST.SENTRY_LABEL.REQUEST_CONFIRMATION_LIST.DISTANCE_FIELD}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import useThemeStyles from '@hooks/useThemeStyles';

import variables from '@styles/variables';

import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import ONYXKEYS from '@src/ONYXKEYS';
import type IconAsset from '@src/types/utils/IconAsset';
Expand Down Expand Up @@ -200,7 +200,7 @@ function ExpenseFieldRow({
// reads that as a non-interactive row and drops the button role and the focus stop with it.
// Otherwise the press is guarded like every other `MenuItem` preset, so an anonymous user gets
// the sign-in prompt rather than the field's selector.
onPress={isInteractive ? callFunctionIfActionIsAllowed(onPress, false, session) : undefined}
onPress={isInteractive ? callIfAuthenticated(onPress, session) : undefined}
isDisabled={isDisabled}
accessibilityLabel={accessibilityLabel}
accessibilityState={isExpanded === undefined ? undefined : {expanded: isExpanded}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Navigation from '@libs/Navigation/Navigation';
import {getCalculatedTaxAmount, getEnabledTaxRateCount, getTaxAmount, getTaxRateTitle} from '@libs/TransactionUtils';

import {setDraftSplitTransaction} from '@userActions/IOU/Split';
import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import CONST from '@src/CONST';
import type {IOUAction, IOUType} from '@src/CONST';
Expand Down Expand Up @@ -219,7 +219,7 @@ function TaxFields({policy, policyForMovingExpenses, iouCurrencyCode, canModifyT
<MenuItem.Root
key={`${taxRates?.name}_rate`}
testID={`${taxRates?.name}_rate`}
onPress={canModifyTaxFields ? callFunctionIfActionIsAllowed(openTaxRatePage, false, session) : undefined}
onPress={canModifyTaxFields ? callIfAuthenticated(openTaxRatePage, session) : undefined}
isDisabled={didConfirm}
sentryLabel={CONST.SENTRY_LABEL.REQUEST_CONFIRMATION_LIST.TAX_RATE_FIELD}
>
Expand Down
4 changes: 2 additions & 2 deletions src/components/PinButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';

import {togglePinnedState} from '@userActions/Report';
import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand All @@ -32,7 +32,7 @@ function PinButton({report}: PinButtonProps) {
return (
<Tooltip text={report.isPinned ? translate('common.unPin') : translate('common.pin')}>
<PressableWithFeedback
onPress={callFunctionIfActionIsAllowed(() => togglePinnedState(report.reportID, report.isPinned ?? false), false, session)}
onPress={callIfAuthenticated(() => togglePinnedState(report.reportID, report.isPinned ?? false), session)}
style={styles.touchableButtonImage}
accessibilityLabel={report.isPinned ? translate('common.unPin') : translate('common.pin')}
role={CONST.ROLE.BUTTON}
Expand Down
16 changes: 6 additions & 10 deletions src/components/PromotedActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Navigation from '@libs/Navigation/Navigation';

import type {IntroSelected} from '@userActions/Report';
import {joinRoom, navigateToAndOpenReport, navigateToAndOpenReportWithAccountIDs, togglePinnedState} from '@userActions/Report';
import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import CONST from '@src/CONST';
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
Expand Down Expand Up @@ -63,7 +63,7 @@ const PromotedActions = {
key: CONST.PROMOTED_ACTIONS.PIN,
icon: 'Pin',
translationKey: report.isPinned ? 'common.unPin' : 'common.pin',
onSelected: callFunctionIfActionIsAllowed(() => togglePinnedState(report.reportID, !!report.isPinned), false, session),
onSelected: callIfAuthenticated(() => togglePinnedState(report.reportID, !!report.isPinned), session),
}),
share: () => ({
key: CONST.PROMOTED_ACTIONS.SHARE,
Expand All @@ -75,14 +75,10 @@ const PromotedActions = {
key: CONST.PROMOTED_ACTIONS.JOIN,
icon: 'ChatBubbles',
translationKey: 'common.join',
onSelected: callFunctionIfActionIsAllowed(
() => {
Navigation.dismissModal();
joinRoom(report, currentUserAccountID);
},
false,
session,
),
onSelected: callIfAuthenticated(() => {
Navigation.dismissModal();
joinRoom(report, currentUserAccountID);
}, session),
}),
message: ({
reportID,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Reactions/AddReactionBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import variables from '@styles/variables';

import {emojiPickerRef, resetEmojiPopoverAnchor, showEmojiPicker} from '@userActions/EmojiPickerAction';
import type {AnchorOrigin} from '@userActions/EmojiPickerAction';
import {callFunctionIfActionIsAllowed} from '@userActions/Session';
import {callIfAuthenticated} from '@userActions/Session';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -103,7 +103,7 @@ function AddReactionBubble({onSelectEmoji, reportAction, onPressOpenPicker, onWi
<PressableWithFeedback
ref={ref}
style={({hovered, pressed}) => [styles.emojiReactionBubble, styles.userSelectNone, StyleUtils.getEmojiReactionBubbleStyle(hovered || pressed, false, isContextMenu)]}
onPress={callFunctionIfActionIsAllowed(onPress, false, session)}
onPress={callIfAuthenticated(onPress, session)}
onMouseDown={(event) => {
// Allow text input blur when Add reaction is right clicked
if (!event || event.button === 2) {
Expand Down
Loading
Loading