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
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8033,6 +8033,7 @@ Hier ist ein *Testbeleg*, um dir zu zeigen, wie es funktioniert:`,
button: 'App herunterladen',
},
notification: {title: 'GPS-Tracking läuft', body: 'Zur App gehen, um abzuschließen'},
signOutWarningTripInProgress: {title: 'GPS-Tracking läuft', prompt: 'Sind Sie sicher, dass Sie die Reise verwerfen und sich abmelden möchten?', confirm: 'Verwerfen und abmelden'},
locationServicesRequiredModal: {
title: 'Standortzugriff erforderlich',
confirm: 'Einstellungen öffnen',
Expand Down
5 changes: 5 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7115,6 +7115,11 @@ const translations = {
title: 'GPS tracking in progress',
body: 'Go to the app to finish',
},
signOutWarningTripInProgress: {
title: 'GPS tracking in progress',
prompt: 'Are you sure you want to discard the trip and sign out?',
confirm: 'Discard and sign out',
},
locationServicesRequiredModal: {
title: 'Location access required',
confirm: 'Open settings',
Expand Down
5 changes: 5 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8142,6 +8142,11 @@ ${amount} para ${merchant} - ${date}`,
title: 'Seguimiento GPS en curso',
body: 'Ve a la app para finalizar',
},
signOutWarningTripInProgress: {
title: 'Seguimiento por GPS en curso',
prompt: '¿Seguro que quieres descartar el viaje y cerrar sesión?',
confirm: 'Descartar y cerrar sesión',
},
locationServicesRequiredModal: {
title: 'Se requiere acceso a la ubicación',
confirm: 'Abrir ajustes',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ const translations: TranslationDeepObject<typeof en> = {
other: 'Voulez-vous vraiment supprimer ces dépenses ?',
}),
deleteReport: 'Supprimer le rapport',
deleteReportConfirmation: 'Voulez-vous vraiment supprimer ce rapport ?',
deleteReportConfirmation: 'Voulez-vous vraiment supprimer ce rapport ?',
settledExpensify: 'Payé',
done: 'Terminé',
settledElsewhere: 'Payé ailleurs',
Expand Down Expand Up @@ -8038,6 +8038,7 @@ Voici un *reçu test* pour vous montrer comment cela fonctionne :`,
subtitle: 'Enregistrez automatiquement les miles ou kilomètres avec le GPS et transformez instantanément vos trajets en dépenses.',
button: 'Télécharger l’application',
},
signOutWarningTripInProgress: {title: 'Suivi GPS en cours', prompt: 'Voulez-vous vraiment abandonner le déplacement et vous déconnecter ?', confirm: 'Ignorer et se déconnecter'},
notification: {title: 'Suivi GPS en cours', body: 'Aller dans l’application pour terminer'},
locationServicesRequiredModal: {
title: 'Accès à la localisation requis',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ const translations: TranslationDeepObject<typeof en> = {
one: 'Sei sicuro di voler eliminare questa spesa?',
other: 'Sei sicuro di voler eliminare queste spese?',
}),
deleteReport: 'Elimina resoconto',
deleteReport: 'Elimina report',
deleteReportConfirmation: 'Sei sicuro di voler eliminare questo report?',
settledExpensify: 'Pagato',
done: 'Fatto',
Expand Down Expand Up @@ -8021,6 +8021,7 @@ Ecco una *ricevuta di prova* per mostrarti come funziona:`,
button: 'Scarica l’app',
},
notification: {title: 'Tracciamento GPS in corso', body: "Vai all'app per terminare"},
signOutWarningTripInProgress: {title: 'Tracciamento GPS in corso', prompt: 'Sei sicuro di voler annullare il viaggio e disconnetterti?', confirm: 'Annulla e disconnettiti'},
locationServicesRequiredModal: {
title: 'È necessario l’accesso alla posizione',
confirm: 'Apri impostazioni',
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7934,6 +7934,7 @@ Expensify の使い方をお見せするための*テストレシート*がこ
},
preciseLocationRequiredModal: {title: '正確な位置情報が必要です', prompt: 'GPS距離の追跡を開始するには、デバイスの設定で「正確な位置情報」を有効にしてください。'},
desktop: {title: 'スマートフォンで距離を記録する', subtitle: 'GPS で自動的にマイルまたはキロメートルを記録し、移動をすぐに経費に変換します。', button: 'アプリをダウンロード'},
signOutWarningTripInProgress: {title: 'GPS追跡を実行中', prompt: 'この出張を破棄してサインアウトしてもよろしいですか?', confirm: '破棄してサインアウト'},
notification: {title: 'GPS追跡を実行中', body: '完了するにはアプリに移動'},
locationServicesRequiredModal: {
title: '位置情報へのアクセスが必要です',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ const translations: TranslationDeepObject<typeof en> = {
other: 'Weet je zeker dat je deze uitgaven wilt verwijderen?',
}),
deleteReport: 'Rapport verwijderen',
deleteReportConfirmation: 'Weet u zeker dat u dit rapport wilt verwijderen?',
deleteReportConfirmation: 'Weet je zeker dat je dit rapport wilt verwijderen?',
settledExpensify: 'Betaald',
done: 'Gereed',
settledElsewhere: 'Elders betaald',
Expand Down Expand Up @@ -7999,6 +7999,7 @@ Hier is een *testbon* om je te laten zien hoe het werkt:`,
preciseLocationRequiredModal: {title: 'Precieze locatie vereist', prompt: 'Schakel "precieze locatie" in de instellingen van je apparaat in om GPS-afstandsregistratie te starten.'},
desktop: {title: 'Volg afstand op je telefoon', subtitle: 'Leg kilometers of mijlen automatisch vast met GPS en zet ritten direct om in uitgaven.', button: 'Download de app'},
notification: {title: 'GPS-tracking bezig', body: 'Ga naar de app om te voltooien'},
signOutWarningTripInProgress: {title: 'GPS-tracking bezig', prompt: 'Weet je zeker dat je de reis wilt weggooien en uitloggen?', confirm: 'Verwerpen en afmelden'},
locationServicesRequiredModal: {
title: 'Locatietoegang vereist',
confirm: 'Instellingen openen',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7982,6 +7982,7 @@ Oto *paragon testowy*, który pokazuje, jak to działa:`,
button: 'Pobierz aplikację',
},
notification: {title: 'Śledzenie GPS w toku', body: 'Przejdź do aplikacji, aby dokończyć'},
signOutWarningTripInProgress: {title: 'Śledzenie GPS w toku', prompt: 'Czy na pewno chcesz porzucić podróż i się wylogować?', confirm: 'Odrzuć i wyloguj się'},
locationServicesRequiredModal: {
title: 'Wymagany dostęp do lokalizacji',
confirm: 'Otwórz ustawienia',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ const translations: TranslationDeepObject<typeof en> = {
other: 'Tem certeza de que deseja excluir estas despesas?',
}),
deleteReport: 'Excluir relatório',
deleteReportConfirmation: 'Você tem certeza de que deseja excluir este relatório?',
deleteReportConfirmation: 'Tem certeza de que deseja excluir este relatório?',
settledExpensify: 'Pago',
done: 'Concluído',
settledElsewhere: 'Pago em outro lugar',
Expand Down Expand Up @@ -7991,6 +7991,7 @@ Aqui está um *recibo de teste* para mostrar como funciona:`,
subtitle: 'Registre milhas ou quilômetros automaticamente com o GPS e transforme viagens em despesas instantaneamente.',
button: 'Baixar o app',
},
signOutWarningTripInProgress: {title: 'Rastreamento por GPS em andamento', prompt: 'Tem certeza de que deseja descartar a viagem e sair?', confirm: 'Descartar e sair'},
notification: {title: 'Rastreamento por GPS em andamento', body: 'Ir para o app para finalizar'},
locationServicesRequiredModal: {
title: 'Acesso à localização obrigatório',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ const translations: TranslationDeepObject<typeof en> = {
other: '您确定要删除这些报销吗?',
}),
deleteReport: '删除报表',
deleteReportConfirmation: '您确定要删除此报表吗?',
deleteReportConfirmation: '您确定要删除此报告吗?',
settledExpensify: '已支付',
done: '完成',
settledElsewhere: '在其他地方已支付',
Expand Down Expand Up @@ -7781,6 +7781,7 @@ ${reportName}
androidBackgroundLocationRequiredModal: {title: '需要后台位置访问权限', prompt: '请在设备设置中允许应用使用“始终允许”位置访问权限,以开始 GPS 距离跟踪。'},
preciseLocationRequiredModal: {title: '需要精确位置', prompt: '请在设备设置中启用“精确位置”以开始 GPS 距离跟踪。'},
desktop: {title: '在手机上跟踪距离', subtitle: '使用 GPS 自动记录英里或公里,并将行程即时转换为报销费用。', button: '下载应用程序'},
signOutWarningTripInProgress: {title: 'GPS 跟踪进行中', prompt: '您确定要放弃此行程并登出吗?', confirm: '放弃并退出'},
notification: {title: '正在进行 GPS 跟踪', body: '前往应用完成'},
locationServicesRequiredModal: {title: '需要访问位置信息', confirm: '打开设置', prompt: '请在设备设置中允许位置访问,以开始 GPS 距离跟踪。'},
fabGpsTripExplained: '前往 GPS 屏幕(悬浮操作)',
Expand Down
23 changes: 19 additions & 4 deletions src/pages/settings/InitialSettingsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {findFocusedRoute, useNavigationState, useRoute} from '@react-navigation/native';
import {differenceInDays} from 'date-fns';
import {stopLocationUpdatesAsync} from 'expo-location';
import React, {useContext, useEffect, useLayoutEffect, useRef, useState} from 'react';
// eslint-disable-next-line no-restricted-imports
import type {GestureResponderEvent, ScrollView as RNScrollView, ScrollViewProps, StyleProp, ViewStyle} from 'react-native';
Expand Down Expand Up @@ -42,6 +43,7 @@ import {getFreeTrialText, hasSubscriptionRedDotError} from '@libs/SubscriptionUt
import {getProfilePageBrickRoadIndicator} from '@libs/UserUtils';
import type SETTINGS_TO_RHP from '@navigation/linkingConfig/RELATIONS/SETTINGS_TO_RHP';
import {showContextMenu} from '@pages/home/report/ContextMenu/ReportActionContextMenu';
import {BACKGROUND_LOCATION_TRACKING_TASK_NAME} from '@pages/iou/request/step/IOURequestStepDistanceGPS/const';
import variables from '@styles/variables';
import {confirmReadyToOpenApp} from '@userActions/App';
import {openExternalLink, openOldDotLink} from '@userActions/Link';
Expand All @@ -55,6 +57,7 @@ import NAVIGATORS from '@src/NAVIGATORS';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type {GpsDraftDetails} from '@src/types/onyx';
import type {Icon as TIcon} from '@src/types/onyx/OnyxCommon';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import type IconAsset from '@src/types/utils/IconAsset';
Expand Down Expand Up @@ -85,6 +88,8 @@ type MenuData = {

type Menu = {sectionStyle: StyleProp<ViewStyle>; sectionTranslationKey: TranslationPaths; items: MenuData[]};

const isTrackingSelector = (gpsDraftDetails?: GpsDraftDetails) => gpsDraftDetails?.isTracking;

function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPageProps) {
const icons = useMemoizedLazyExpensifyIcons([
'Gear',
Expand Down Expand Up @@ -131,6 +136,7 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
const isScreenFocused = useIsSidebarRouteActive(NAVIGATORS.SETTINGS_SPLIT_NAVIGATOR, shouldUseNarrowLayout);
const hasActivatedWallet = ([CONST.WALLET.TIER_NAME.GOLD, CONST.WALLET.TIER_NAME.PLATINUM] as string[]).includes(userWallet?.tierName ?? '');
const [firstDayFreeTrial] = useOnyx(ONYXKEYS.NVP_FIRST_DAY_FREE_TRIAL, {canBeMissing: true});
const [isTrackingGPS] = useOnyx(ONYXKEYS.GPS_DRAFT_DETAILS, {canBeMissing: true, selector: isTrackingSelector});
const [lastDayFreeTrial] = useOnyx(ONYXKEYS.NVP_LAST_DAY_FREE_TRIAL, {canBeMissing: true});
const [unsharedBankAccount] = useOnyx(ONYXKEYS.UNSHARE_BANK_ACCOUNT, {canBeMissing: true});
const privateSubscription = usePrivateSubscription();
Expand Down Expand Up @@ -183,7 +189,7 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
};

const signOut = (shouldForceSignout = false) => {
if (!network.isOffline || shouldForceSignout) {
if ((!network.isOffline && !isTrackingGPS) || shouldForceSignout) {
return signOutAndRedirectToSignIn();
}

Expand Down Expand Up @@ -468,6 +474,10 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
scrollViewRef.current.scrollTo({y: scrollOffset, animated: false});
}, [getScrollOffset, route]);

const confirmModalTitle = isTrackingGPS ? translate('gps.signOutWarningTripInProgress.title') : translate('common.areYouSure');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the title should depend on both isTrackingGPS and offline. It'd be better if we create the variable and reuse it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that for isTrackingGPS and offline mode scenario the title should be different? I discussed that with @dubielzyk-expensify and we decided to do it like this => GPS copy for isTracking === true no matter if it's offline mode or not

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I got it. Thanks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly what @GCyganek says 👍

const confirmModalPrompt = isTrackingGPS ? translate('gps.signOutWarningTripInProgress.prompt') : translate('initialSettingsPage.signOutConfirmationText');
const confirmModalConfirmText = isTrackingGPS ? translate('gps.signOutWarningTripInProgress.confirm') : translate('initialSettingsPage.signOut');

return (
<ScreenWrapper
includeSafeAreaPaddingBottom
Expand All @@ -488,12 +498,17 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
{generalMenuItems}
<ConfirmModal
danger
title={translate('common.areYouSure')}
prompt={translate('initialSettingsPage.signOutConfirmationText')}
confirmText={translate('initialSettingsPage.signOut')}
title={confirmModalTitle}
prompt={confirmModalPrompt}
confirmText={confirmModalConfirmText}
cancelText={translate('common.cancel')}
isVisible={shouldShowSignoutConfirmModal}
onConfirm={() => {
if (isTrackingGPS) {
stopLocationUpdatesAsync(BACKGROUND_LOCATION_TRACKING_TASK_NAME).catch((error) =>
console.error('[GPS distance request] Failed to stop location tracking', error),
);
}
toggleSignoutConfirmModal(false);
shouldLogout.current = true;
}}
Expand Down
Loading