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

DO NOT MERGE -- test removal of 7 day location logic #52176

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions src/components/LocationPermissionModal/index.android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ function LocationPermissionModal({startPermissionFlow, resetPermissionFlow, onDe
setHasError(true);
return;
} else {
onDeny(status);
onDeny();
}
setShowModal(false);
setHasError(false);
});
});

const skipLocationPermission = () => {
onDeny(RESULTS.DENIED);
onDeny();
setShowModal(false);
setHasError(false);
};
Expand Down
20 changes: 14 additions & 6 deletions src/components/LocationPermissionModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useEffect, useState} from 'react';
import React, {useEffect, useMemo, useState} from 'react';
import {Linking} from 'react-native';
import {RESULTS} from 'react-native-permissions';
import ConfirmModal from '@components/ConfirmModal';
Expand Down Expand Up @@ -39,10 +39,10 @@ function LocationPermissionModal({startPermissionFlow, resetPermissionFlow, onDe
if (hasError) {
if (Linking.openSettings) {
Linking.openSettings();
} else {
onDeny?.();
}
setShowModal(false);
setHasError(false);
resetPermissionFlow();
return;
}
cb();
Expand All @@ -54,7 +54,7 @@ function LocationPermissionModal({startPermissionFlow, resetPermissionFlow, onDe
if (status === RESULTS.GRANTED || status === RESULTS.LIMITED) {
onGrant();
} else {
onDeny(status);
onDeny();
}
})
.finally(() => {
Expand All @@ -64,7 +64,7 @@ function LocationPermissionModal({startPermissionFlow, resetPermissionFlow, onDe
});

const skipLocationPermission = () => {
onDeny(RESULTS.DENIED);
onDeny();
setShowModal(false);
setHasError(false);
};
Expand All @@ -81,15 +81,22 @@ function LocationPermissionModal({startPermissionFlow, resetPermissionFlow, onDe
setShowModal(false);
resetPermissionFlow();
};

const locationErrorMessage = useMemo(() => (isWeb ? 'receipt.allowLocationFromSetting' : 'receipt.locationErrorMessage'), [isWeb]);

return (
<ConfirmModal
shouldShowCancelButton={!(isWeb && hasError)}
onModalHide={() => {
setHasError(false);
resetPermissionFlow();
}}
isVisible={showModal}
onConfirm={grantLocationPermission}
onCancel={skipLocationPermission}
onBackdropPress={closeModal}
confirmText={getConfirmText()}
cancelText={translate('common.notNow')}
prompt={translate(hasError ? 'receipt.locationErrorMessage' : 'receipt.locationAccessMessage')}
promptStyles={[styles.textLabelSupportingEmptyValue, styles.mb4]}
title={translate(hasError ? 'receipt.locationErrorTitle' : 'receipt.locationAccessTitle')}
titleContainerStyles={[styles.mt2, styles.mb0]}
Expand All @@ -100,6 +107,7 @@ function LocationPermissionModal({startPermissionFlow, resetPermissionFlow, onDe
iconHeight={120}
shouldCenterIcon
shouldReverseStackedButtons
prompt={translate(hasError ? locationErrorMessage : 'receipt.locationAccessMessage')}
/>
);
}
Expand Down
4 changes: 1 addition & 3 deletions src/components/LocationPermissionModal/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type {PermissionStatus} from 'react-native-permissions';

type LocationPermissionModalProps = {
/** A callback to call when the permission has been granted */
onGrant: () => void;

/** A callback to call when the permission has been denied */
onDeny: (permission: PermissionStatus) => void;
onDeny: () => void;

/** Should start the permission flow? */
startPermissionFlow: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ const translations = {
locationAccessMessage: 'Location access helps us keep your timezone and currency accurate wherever you go.',
locationErrorTitle: 'Allow location access',
locationErrorMessage: 'Location access helps us keep your timezone and currency accurate wherever you go.',
allowLocationFromSetting: `Location access helps us keep your timezone and currency accurate wherever you go. Please allow location access from your device's permission settings.`,
dropTitle: 'Let it go',
dropMessage: 'Drop your file here',
flash: 'flash',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ const translations = {
locationAccessMessage: 'El acceso a la ubicación nos ayuda a mantener tu zona horaria y moneda precisas dondequiera que vayas.',
locationErrorTitle: 'Permitir acceso a la ubicación',
locationErrorMessage: 'El acceso a la ubicación nos ayuda a mantener tu zona horaria y moneda precisas dondequiera que vayas.',
allowLocationFromSetting: `El acceso a la ubicación nos ayuda a mantener tu zona horaria y moneda precisas dondequiera que estés. Por favor, permite el acceso a la ubicación en la configuración de permisos de tu dispositivo.`,
cameraErrorMessage: 'Se ha producido un error al hacer una foto. Por favor, inténtalo de nuevo.',
dropTitle: 'Suéltalo',
dropMessage: 'Suelta tu archivo aquí',
Expand Down
5 changes: 1 addition & 4 deletions src/pages/iou/request/step/IOURequestStepConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import useNetwork from '@hooks/useNetwork';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import DateUtils from '@libs/DateUtils';

Check failure on line 18 in src/pages/iou/request/step/IOURequestStepConfirmation.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'DateUtils' is defined but never used

Check failure on line 18 in src/pages/iou/request/step/IOURequestStepConfirmation.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'DateUtils' is defined but never used
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import * as FileUtils from '@libs/fileDownload/FileUtils';
import getCurrentPosition from '@libs/getCurrentPosition';
Expand Down Expand Up @@ -586,10 +586,7 @@
setSelectedParticipantList(listOfParticipants);

if (gpsRequired) {
const shouldStartLocationPermissionFlow =
!lastLocationPermissionPrompt ||
(DateUtils.isValidDateString(lastLocationPermissionPrompt ?? '') &&
DateUtils.getDifferenceInDaysFromNow(new Date(lastLocationPermissionPrompt ?? '')) > CONST.IOU.LOCATION_PERMISSION_PROMPT_THRESHOLD_DAYS);
const shouldStartLocationPermissionFlow = !lastLocationPermissionPrompt;

if (shouldStartLocationPermissionFlow) {
setStartLocationPermissionFlow(true);
Expand Down
Loading