From 98a52fc64c35f5de78832f2b662d64c61c9ee8ac Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Sun, 10 Mar 2024 22:21:50 +0700 Subject: [PATCH 001/133] Add new welcome note --- src/languages/en.ts | 10 ++++- src/languages/types.ts | 2 +- .../workspace/WorkspaceInviteMessagePage.tsx | 42 +++++++++++++------ 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 3575854ee7e2..302a039d697c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1906,8 +1906,14 @@ export default { personalMessagePrompt: 'Message', genericFailureMessage: 'An error occurred inviting the user to the workspace, please try again.', inviteNoMembersError: 'Please select at least one member to invite', - welcomeNote: ({workspaceName}: WelcomeNoteParams) => - `You have been invited to ${workspaceName || 'a workspace'}! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.`, + welcomeNote: ({workspaceName, senderDisplayName, senderLogin, workspaceDescription, workspaceLink}: WelcomeNoteParams) => `${ + senderDisplayName ? `#${senderDisplayName} (${senderLogin}) invited you to Expensify` : `#${senderLogin} invited you to Expensify` + }\nHi there -\n\nTo join "${workspaceName}", [click here](${workspaceLink}) to start tracking your expenses!\n\nThey also added the message:\nYou have been invited to ${ + workspaceName || 'a workspace' + }! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.\n\n${ + workspaceDescription ? `Additionally, here is the workspace description:\n ${workspaceDescription}` : '' + } + `, }, editor: { descriptionInputLabel: 'Description', diff --git a/src/languages/types.ts b/src/languages/types.ts index 2bb05b614483..a2f4c92c7a3c 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -184,7 +184,7 @@ type UserIsAlreadyMemberParams = {login: string; name: string}; type GoToRoomParams = {roomName: string}; -type WelcomeNoteParams = {workspaceName: string}; +type WelcomeNoteParams = {workspaceName: string; senderDisplayName: string; senderLogin: string; workspaceDescription: string; workspaceLink: string}; type RoomNameReservedErrorParams = {reservedName: string}; diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.tsx b/src/pages/workspace/WorkspaceInviteMessagePage.tsx index 72f08095b58a..4961990d69b5 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx +++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx @@ -1,4 +1,5 @@ import type {StackScreenProps} from '@react-navigation/stack'; +import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import lodashDebounce from 'lodash/debounce'; import React, {useEffect, useState} from 'react'; import {Keyboard, View} from 'react-native'; @@ -16,6 +17,8 @@ import type {AnimatedTextInputRef} from '@components/RNTextInput'; import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; +import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; +import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -50,11 +53,20 @@ type WorkspaceInviteMessagePageOnyxProps = { type WorkspaceInviteMessagePageProps = WithPolicyAndFullscreenLoadingProps & WorkspaceInviteMessagePageOnyxProps & + WithCurrentUserPersonalDetailsProps & StackScreenProps; -function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsToAccountIDsDraft, policy, route, allPersonalDetails}: WorkspaceInviteMessagePageProps) { +function WorkspaceInviteMessagePage({ + workspaceInviteMessageDraft, + invitedEmailsToAccountIDsDraft, + policy, + route, + allPersonalDetails, + currentUserPersonalDetails, +}: WorkspaceInviteMessagePageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); + const parser = new ExpensiMark(); const [welcomeNote, setWelcomeNote] = useState(); @@ -66,6 +78,10 @@ function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsT workspaceInviteMessageDraft || translate('workspace.inviteMessage.welcomeNote', { workspaceName: policy?.name ?? '', + senderDisplayName: currentUserPersonalDetails?.displayName ?? '', + senderLogin: currentUserPersonalDetails?.login ?? '', + workspaceDescription: parser.htmlToMarkdown(policy?.description ?? ''), + workspaceLink: ROUTES.WORKSPACE_PROFILE.getRoute(route.params.policyID), }); useEffect(() => { @@ -200,15 +216,17 @@ function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsT WorkspaceInviteMessagePage.displayName = 'WorkspaceInviteMessagePage'; export default withPolicyAndFullscreenLoading( - withOnyx({ - allPersonalDetails: { - key: ONYXKEYS.PERSONAL_DETAILS_LIST, - }, - invitedEmailsToAccountIDsDraft: { - key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`, - }, - workspaceInviteMessageDraft: { - key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${route.params.policyID.toString()}`, - }, - })(WorkspaceInviteMessagePage), + withCurrentUserPersonalDetails( + withOnyx({ + allPersonalDetails: { + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + }, + invitedEmailsToAccountIDsDraft: { + key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`, + }, + workspaceInviteMessageDraft: { + key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${route.params.policyID.toString()}`, + }, + })(WorkspaceInviteMessagePage), + ), ); From a9165f3a6e3e25af759b9abcdb2b9644a43b5048 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 14 Mar 2024 01:13:38 +0700 Subject: [PATCH 002/133] add welcome note es --- src/languages/en.ts | 2 +- src/languages/es.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 8c120d58fa3c..a27635b100c7 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1966,7 +1966,7 @@ export default { inviteNoMembersError: 'Please select at least one member to invite', welcomeNote: ({workspaceName, senderDisplayName, senderLogin, workspaceDescription, workspaceLink}: WelcomeNoteParams) => `${ senderDisplayName ? `#${senderDisplayName} (${senderLogin}) invited you to Expensify` : `#${senderLogin} invited you to Expensify` - }\nHi there -\n\nTo join "${workspaceName}", [click here](${workspaceLink}) to start tracking your expenses!\n\nThey also added the message:\nYou have been invited to ${ + }\nHi there 1 -\n\nTo join "${workspaceName}", [click here](${workspaceLink}) to start tracking your expenses!\n\nThey also added the message:\nYou have been invited to ${ workspaceName || 'a workspace' }! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.\n\n${ workspaceDescription ? `Additionally, here is the workspace description:\n ${workspaceDescription}` : '' diff --git a/src/languages/es.ts b/src/languages/es.ts index 267581f043ee..d76790b1281d 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1989,8 +1989,14 @@ export default { personalMessagePrompt: 'Mensaje', inviteNoMembersError: 'Por favor, selecciona al menos un miembro a invitar', genericFailureMessage: 'Se produjo un error al invitar al usuario al espacio de trabajo. Vuelva a intentarlo..', - welcomeNote: ({workspaceName}: WelcomeNoteParams) => - `¡Has sido invitado a ${workspaceName}! Descargue la aplicación móvil Expensify en use.expensify.com/download para comenzar a rastrear sus gastos.`, + welcomeNote: ({workspaceName, senderDisplayName, senderLogin, workspaceDescription, workspaceLink}: WelcomeNoteParams) => `${ + senderDisplayName ? `#${senderDisplayName} (${senderLogin}) te invitó a Expensify` : `#${senderLogin} te invitó a Expensify` + }\n¡Hola! -\n\nPara unirte a "${workspaceName}", [haz clic aquí](${workspaceLink}) para empezar a seguir tus gastos!\n\nTambién añadieron el mensaje:\nHas sido invitado a ${ + workspaceName || 'un espacio de trabajo' + }! Descarga la aplicación móvil de Expensify en use.expensify.com/download para empezar a seguir tus gastos.\n\n${ + workspaceDescription ? `Además, aquí está la descripción del espacio de trabajo:\n ${workspaceDescription}` : '' + } + `, }, distanceRates: { oopsNotSoFast: 'Ups! No tan rápido...', From 0d13ebc2cf2edbc626504f6ef81efaed9aa7c955 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Sat, 23 Mar 2024 00:39:36 +0300 Subject: [PATCH 003/133] fix chat thread reimbursement queued action bugs --- src/libs/ReportActionsUtils.ts | 2 +- src/libs/ReportUtils.ts | 23 +++++++++++++++++----- src/pages/home/report/ReportActionItem.tsx | 9 +++++---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 05701c3e321f..a163cefd43a3 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -187,7 +187,7 @@ function isThreadParentMessage(reportAction: OnyxEntry, reportID: * * @deprecated Use Onyx.connect() or withOnyx() instead */ -function getParentReportAction(report: OnyxEntry | EmptyObject): ReportAction | Record { +function getParentReportAction(report: OnyxEntry | EmptyObject): ReportAction | EmptyObject { if (!report?.parentReportID || !report.parentReportActionID) { return {}; } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index d0ce53a0e10b..c4ebe2335fba 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2731,6 +2731,23 @@ function getAdminRoomInvitedParticipants(parentReportAction: ReportAction | Reco return roomName ? `${verb} ${users} ${preposition} ${roomName}` : `${verb} ${users}`; } +/** + * Get the report action message for a report action. + */ + +function getReportActionMessage(reportAction: ReportAction | EmptyObject, parentReportID?: string) { + if (isEmptyObject(reportAction)) { + return ''; + } + if (ReportActionsUtils.isApprovedOrSubmittedReportAction(reportAction)) { + return ReportActionsUtils.getReportActionMessageText(reportAction); + } + if (ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { + return getReimbursementQueuedActionMessage(reportAction, getReport(parentReportID) as OnyxEntry, false); + } + return reportAction?.message?.[0]?.text ?? ''; +} + /** * Get the title for a report. */ @@ -2751,11 +2768,7 @@ function getReportName(report: OnyxEntry, policy: OnyxEntry = nu } const isAttachment = ReportActionsUtils.isReportActionAttachment(!isEmptyObject(parentReportAction) ? parentReportAction : null); - const parentReportActionMessage = ( - ReportActionsUtils.isApprovedOrSubmittedReportAction(parentReportAction) - ? ReportActionsUtils.getReportActionMessageText(parentReportAction) - : parentReportAction?.message?.[0]?.text ?? '' - ).replace(/(\r\n|\n|\r)/gm, ' '); + const parentReportActionMessage = getReportActionMessage(parentReportAction, report?.parentReportID).replace(/(\r\n|\n|\r)/gm, ' '); if (isAttachment && parentReportActionMessage) { return `[${Localize.translateLocal('common.attachment')}]`; } diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 0e8b0cf97d1e..8971bd2af970 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -466,10 +466,11 @@ function ReportActionItem({ ); } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENTQUEUED) { - const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails[report.ownerAccountID ?? -1]); + const linkedReport = ReportUtils.isChatThread(report) ? ReportUtils.getReport(report.parentReportID) : report; + const submitterDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails[linkedReport?.ownerAccountID ?? -1]); const paymentType = action.originalMessage.paymentType ?? ''; - const missingPaymentMethod = ReportUtils.getIndicatedMissingPaymentMethod(userWallet, report.reportID, action); + const missingPaymentMethod = ReportUtils.getIndicatedMissingPaymentMethod(userWallet, linkedReport?.reportID ?? '', action); children = ( BankAccounts.openPersonalBankAccountSetupView(report.reportID)} + onPress={() => BankAccounts.openPersonalBankAccountSetupView(linkedReport?.reportID)} pressOnEnter large /> @@ -491,7 +492,7 @@ function ReportActionItem({ enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} addBankAccountRoute={ROUTES.BANK_ACCOUNT_PERSONAL} addDebitCardRoute={ROUTES.SETTINGS_ADD_DEBIT_CARD} - chatReportID={report.reportID} + chatReportID={linkedReport?.reportID} iouReport={iouReport} > {(triggerKYCFlow, buttonRef) => ( From 8045460bdc940c5015d20a6ce43b03a6f438069f Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sun, 24 Mar 2024 16:43:00 +0800 Subject: [PATCH 004/133] revert #34075 --- src/libs/actions/IOU.ts | 18 +---- .../iou/request/step/IOURequestStepAmount.js | 28 ++----- .../step/IOURequestStepConfirmation.js | 79 ++++++++----------- .../request/step/IOURequestStepCurrency.js | 14 +++- .../step/IOURequestStepTaxAmountPage.js | 29 ++----- 5 files changed, 54 insertions(+), 114 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 5632268ef6ca..2e7c36115641 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -329,11 +329,7 @@ function startMoneyRequest(iouType: ValueOf, reportID: st } // eslint-disable-next-line @typescript-eslint/naming-convention -function setMoneyRequestAmount_temporaryForRefactor(transactionID: string, amount: number, currency: string, removeOriginalCurrency = false) { - if (removeOriginalCurrency) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {amount, currency, originalCurrency: null}); - return; - } +function setMoneyRequestAmount_temporaryForRefactor(transactionID: string, amount: number, currency: string) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {amount, currency}); } @@ -343,19 +339,10 @@ function setMoneyRequestCreated(transactionID: string, created: string, isDraft: } // eslint-disable-next-line @typescript-eslint/naming-convention -function setMoneyRequestCurrency_temporaryForRefactor(transactionID: string, currency: string, removeOriginalCurrency = false) { - if (removeOriginalCurrency) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {currency, originalCurrency: null}); - return; - } +function setMoneyRequestCurrency_temporaryForRefactor(transactionID: string, currency: string) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {currency}); } -// eslint-disable-next-line @typescript-eslint/naming-convention -function setMoneyRequestOriginalCurrency_temporaryForRefactor(transactionID: string, originalCurrency: string) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {originalCurrency}); -} - function setMoneyRequestDescription(transactionID: string, comment: string, isDraft: boolean) { Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {comment: {comment: comment.trim()}}); } @@ -5179,7 +5166,6 @@ export { setMoneyRequestCreated, setMoneyRequestCurrency_temporaryForRefactor, setMoneyRequestDescription, - setMoneyRequestOriginalCurrency_temporaryForRefactor, setMoneyRequestParticipants_temporaryForRefactor, setMoneyRequestPendingFields, setMoneyRequestReceipt, diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 9fdd2bea24f4..740cbe105a57 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -1,7 +1,7 @@ import {useFocusEffect} from '@react-navigation/native'; import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; -import React, {useCallback, useEffect, useRef} from 'react'; +import React, {useCallback, useRef} from 'react'; import {withOnyx} from 'react-native-onyx'; import taxPropTypes from '@components/taxPropTypes'; import transactionPropTypes from '@components/transactionPropTypes'; @@ -67,18 +67,17 @@ const getTaxAmount = (transaction, defaultTaxValue, amount) => { function IOURequestStepAmount({ report, route: { - params: {iouType, reportID, transactionID, backTo}, + params: {iouType, reportID, transactionID, backTo, currency: selectedCurrency}, }, transaction, - transaction: {currency}, + transaction: {currency: originalCurrency}, policy, }) { const {translate} = useLocalize(); const textInput = useRef(null); const focusTimeoutRef = useRef(null); - const isSaveButtonPressed = useRef(false); - const originalCurrency = useRef(null); const iouRequestType = getRequestType(transaction); + const currency = selectedCurrency || originalCurrency; const taxRates = lodashGet(policy, 'taxRates', {}); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(report)); @@ -96,22 +95,6 @@ function IOURequestStepAmount({ }, []), ); - useEffect(() => { - if (transaction.originalCurrency) { - originalCurrency.current = transaction.originalCurrency; - } else { - originalCurrency.current = currency; - IOU.setMoneyRequestOriginalCurrency_temporaryForRefactor(transactionID, currency); - } - return () => { - if (isSaveButtonPressed.current) { - return; - } - IOU.setMoneyRequestCurrency_temporaryForRefactor(transactionID, originalCurrency.current, true); - }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - const navigateBack = () => { Navigation.goBack(backTo); }; @@ -124,7 +107,6 @@ function IOURequestStepAmount({ * @param {Number} amount */ const navigateToNextPage = ({amount}) => { - isSaveButtonPressed.current = true; const amountInSmallestCurrencyUnits = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); if ((iouRequestType === CONST.IOU.REQUEST_TYPE.MANUAL || backTo) && isTaxTrackingEnabled) { @@ -133,7 +115,7 @@ function IOURequestStepAmount({ IOU.setMoneyRequestTaxAmount(transaction.transactionID, taxAmountInSmallestCurrencyUnits); } - IOU.setMoneyRequestAmount_temporaryForRefactor(transactionID, amountInSmallestCurrencyUnits, currency || CONST.CURRENCY.USD, true); + IOU.setMoneyRequestAmount_temporaryForRefactor(transactionID, amountInSmallestCurrencyUnits, currency || CONST.CURRENCY.USD); if (backTo) { Navigation.goBack(backTo); diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index 435121a76028..7c5683974a0e 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -5,7 +5,6 @@ import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import categoryPropTypes from '@components/categoryPropTypes'; -import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Expensicons from '@components/Icon/Expensicons'; import MoneyRequestConfirmationList from '@components/MoneyTemporaryForRefactorRequestConfirmationList'; @@ -120,15 +119,6 @@ function IOURequestStepConfirmation({ const isPolicyExpenseChat = useMemo(() => ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(report)), [report]); const formHasBeenSubmitted = useRef(false); - useEffect(() => { - if (!transaction || !transaction.originalCurrency) { - return; - } - // If user somehow lands on this page without the currency reset, then reset it here. - IOU.setMoneyRequestCurrency_temporaryForRefactor(transactionID, transaction.originalCurrency, true); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - useEffect(() => { const policyExpenseChat = _.find(participants, (participant) => participant.isPolicyExpenseChat); if (policyExpenseChat) { @@ -492,10 +482,6 @@ function IOURequestStepConfirmation({ IOU.setMoneyRequestBillable_temporaryForRefactor(transactionID, billable); }; - // This loading indicator is shown because the transaction originalCurrency is being updated later than the component mounts. - // To prevent the component from rendering with the wrong currency, we show a loading indicator until the correct currency is set. - const isLoading = !!(transaction && transaction.originalCurrency); - return ( - {isLoading && } - - - + )} diff --git a/src/pages/iou/request/step/IOURequestStepCurrency.js b/src/pages/iou/request/step/IOURequestStepCurrency.js index 43e4e9bf0eaa..49bfbd8355d7 100644 --- a/src/pages/iou/request/step/IOURequestStepCurrency.js +++ b/src/pages/iou/request/step/IOURequestStepCurrency.js @@ -60,14 +60,18 @@ function IOURequestStepCurrency({ const [searchValue, setSearchValue] = useState(''); const optionsSelectorRef = useRef(); - const navigateBack = () => { + const navigateBack = (selectedCurrency = undefined) => { // If the currency selection was done from the confirmation step (eg. + > request money > manual > confirm > amount > currency) // then the user needs taken back to the confirmation page instead of the initial amount page. This is because the route params // are only able to handle one backTo param at a time and the user needs to go back to the amount page before going back // to the confirmation page if (pageIndex === 'confirm') { const routeToAmountPageWithConfirmationAsBackTo = getUrlWithBackToParam(backTo, `/${ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)}`); - Navigation.goBack(routeToAmountPageWithConfirmationAsBackTo); + if (selectedCurrency) { + Navigation.navigate(`${routeToAmountPageWithConfirmationAsBackTo}¤cy=${selectedCurrency}`); + } else { + Navigation.goBack(routeToAmountPageWithConfirmationAsBackTo); + } return; } Navigation.goBack(backTo); @@ -79,8 +83,10 @@ function IOURequestStepCurrency({ */ const confirmCurrencySelection = (option) => { Keyboard.dismiss(); - IOU.setMoneyRequestCurrency_temporaryForRefactor(transactionID, option.currencyCode); - navigateBack(); + if (pageIndex !== 'confirm') { + IOU.setMoneyRequestCurrency_temporaryForRefactor(transactionID, option.currencyCode); + } + navigateBack(option.currencyCode); }; const {sections, headerMessage, initiallyFocusedOptionKey} = useMemo(() => { diff --git a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js index 7a75e9f48805..292ad78dac45 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js @@ -1,7 +1,7 @@ import {useFocusEffect} from '@react-navigation/native'; import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; -import React, {useCallback, useEffect, useRef} from 'react'; +import React, {useCallback, useRef} from 'react'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; @@ -58,10 +58,10 @@ const getTaxAmount = (transaction, defaultTaxValue) => { function IOURequestStepTaxAmountPage({ route: { - params: {iouType, reportID, transactionID, backTo}, + params: {iouType, reportID, transactionID, backTo, currency: selectedCurrency}, }, transaction, - transaction: {currency}, + transaction: {currency: originalCurrency}, report, policy, }) { @@ -70,28 +70,12 @@ function IOURequestStepTaxAmountPage({ const textInput = useRef(null); const isEditing = Navigation.getActiveRoute().includes('taxAmount'); + const currency = selectedCurrency || originalCurrency; + const focusTimeoutRef = useRef(null); - const isSaveButtonPressed = useRef(false); - const originalCurrency = useRef(null); const taxRates = lodashGet(policy, 'taxRates', {}); - useEffect(() => { - if (transaction.originalCurrency) { - originalCurrency.current = transaction.originalCurrency; - } else { - originalCurrency.current = currency; - IOU.setMoneyRequestOriginalCurrency_temporaryForRefactor(transactionID, currency); - } - return () => { - if (isSaveButtonPressed.current) { - return; - } - IOU.setMoneyRequestCurrency_temporaryForRefactor(transactionID, originalCurrency.current, true); - }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - useFocusEffect( useCallback(() => { focusTimeoutRef.current = setTimeout(() => textInput.current && textInput.current.focus(), CONST.ANIMATED_TRANSITION); @@ -116,11 +100,10 @@ function IOURequestStepTaxAmountPage({ }; const updateTaxAmount = (currentAmount) => { - isSaveButtonPressed.current = true; const amountInSmallestCurrencyUnits = CurrencyUtils.convertToBackendAmount(Number.parseFloat(currentAmount.amount)); IOU.setMoneyRequestTaxAmount(transactionID, amountInSmallestCurrencyUnits); - IOU.setMoneyRequestCurrency_temporaryForRefactor(transactionID, currency || CONST.CURRENCY.USD, true); + IOU.setMoneyRequestCurrency_temporaryForRefactor(transactionID, currency || CONST.CURRENCY.USD); if (backTo) { Navigation.goBack(backTo); From 90a53e011929f92c158a5b1bd981bbde3679a056 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sun, 24 Mar 2024 16:57:03 +0800 Subject: [PATCH 005/133] allow currency page to accept currency params and show it if available --- src/ROUTES.ts | 4 ++-- src/pages/iou/request/step/IOURequestStepAmount.js | 2 +- src/pages/iou/request/step/IOURequestStepCurrency.js | 11 ++++++----- .../iou/request/step/IOURequestStepTaxAmountPage.js | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index c216d5ac288c..c41dc0558da5 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -335,8 +335,8 @@ const ROUTES = { }, MONEY_REQUEST_STEP_CURRENCY: { route: 'create/:iouType/currency/:transactionID/:reportID/:pageIndex?', - getRoute: (iouType: ValueOf, transactionID: string, reportID: string, pageIndex = '', backTo = '') => - getUrlWithBackToParam(`create/${iouType}/currency/${transactionID}/${reportID}/${pageIndex}`, backTo), + getRoute: (iouType: ValueOf, transactionID: string, reportID: string, pageIndex = '', currency = '', backTo = '') => + getUrlWithBackToParam(`create/${iouType}/currency/${transactionID}/${reportID}/${pageIndex}?currency=${currency}`, backTo), }, MONEY_REQUEST_STEP_DATE: { route: ':action/:iouType/date/:transactionID/:reportID', diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index 740cbe105a57..fd70c69e88c3 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -100,7 +100,7 @@ function IOURequestStepAmount({ }; const navigateToCurrencySelectionPage = () => { - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CURRENCY.getRoute(iouType, transactionID, reportID, backTo ? 'confirm' : '', Navigation.getActiveRouteWithoutParams())); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CURRENCY.getRoute(iouType, transactionID, reportID, backTo ? 'confirm' : '', currency, Navigation.getActiveRouteWithoutParams())); }; /** diff --git a/src/pages/iou/request/step/IOURequestStepCurrency.js b/src/pages/iou/request/step/IOURequestStepCurrency.js index 49bfbd8355d7..5af9d27dbda1 100644 --- a/src/pages/iou/request/step/IOURequestStepCurrency.js +++ b/src/pages/iou/request/step/IOURequestStepCurrency.js @@ -52,23 +52,24 @@ const defaultProps = { function IOURequestStepCurrency({ currencyList, route: { - params: {backTo, iouType, pageIndex, reportID, transactionID}, + params: {backTo, iouType, pageIndex, reportID, transactionID, currency: selectedCurrency}, }, - transaction: {currency}, + transaction: {currency: originalCurrency}, }) { const {translate} = useLocalize(); const [searchValue, setSearchValue] = useState(''); const optionsSelectorRef = useRef(); + const currency = selectedCurrency || originalCurrency; - const navigateBack = (selectedCurrency = undefined) => { + const navigateBack = (selectedCurrencyValue = undefined) => { // If the currency selection was done from the confirmation step (eg. + > request money > manual > confirm > amount > currency) // then the user needs taken back to the confirmation page instead of the initial amount page. This is because the route params // are only able to handle one backTo param at a time and the user needs to go back to the amount page before going back // to the confirmation page if (pageIndex === 'confirm') { const routeToAmountPageWithConfirmationAsBackTo = getUrlWithBackToParam(backTo, `/${ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)}`); - if (selectedCurrency) { - Navigation.navigate(`${routeToAmountPageWithConfirmationAsBackTo}¤cy=${selectedCurrency}`); + if (selectedCurrencyValue) { + Navigation.navigate(`${routeToAmountPageWithConfirmationAsBackTo}¤cy=${selectedCurrencyValue}`); } else { Navigation.goBack(routeToAmountPageWithConfirmationAsBackTo); } diff --git a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js index 292ad78dac45..32e70fec5e16 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js @@ -96,7 +96,7 @@ function IOURequestStepTaxAmountPage({ // If the money request being created is a distance request, don't allow the user to choose the currency. // Only USD is allowed for distance requests. // Remove query from the route and encode it. - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CURRENCY.getRoute(iouType, transactionID, reportID, backTo ? 'confirm' : '', Navigation.getActiveRouteWithoutParams())); + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CURRENCY.getRoute(iouType, transactionID, reportID, backTo ? 'confirm' : '', currency, Navigation.getActiveRouteWithoutParams())); }; const updateTaxAmount = (currentAmount) => { From b6f1979d8a939fafb45adae396a83880b1c7c603 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Sun, 24 Mar 2024 17:00:17 +0800 Subject: [PATCH 006/133] show saved currency if the currency param is invalid --- src/pages/iou/request/step/IOURequestStepAmount.js | 2 +- src/pages/iou/request/step/IOURequestStepCurrency.js | 2 +- src/pages/iou/request/step/IOURequestStepTaxAmountPage.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.js b/src/pages/iou/request/step/IOURequestStepAmount.js index fd70c69e88c3..0c8af94ad841 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.js +++ b/src/pages/iou/request/step/IOURequestStepAmount.js @@ -77,7 +77,7 @@ function IOURequestStepAmount({ const textInput = useRef(null); const focusTimeoutRef = useRef(null); const iouRequestType = getRequestType(transaction); - const currency = selectedCurrency || originalCurrency; + const currency = CurrencyUtils.isValidCurrencyCode(selectedCurrency) ? selectedCurrency : originalCurrency; const taxRates = lodashGet(policy, 'taxRates', {}); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(report)); diff --git a/src/pages/iou/request/step/IOURequestStepCurrency.js b/src/pages/iou/request/step/IOURequestStepCurrency.js index 5af9d27dbda1..53d04a0ae0ed 100644 --- a/src/pages/iou/request/step/IOURequestStepCurrency.js +++ b/src/pages/iou/request/step/IOURequestStepCurrency.js @@ -59,7 +59,7 @@ function IOURequestStepCurrency({ const {translate} = useLocalize(); const [searchValue, setSearchValue] = useState(''); const optionsSelectorRef = useRef(); - const currency = selectedCurrency || originalCurrency; + const currency = CurrencyUtils.isValidCurrencyCode(selectedCurrency) ? selectedCurrency : originalCurrency; const navigateBack = (selectedCurrencyValue = undefined) => { // If the currency selection was done from the confirmation step (eg. + > request money > manual > confirm > amount > currency) diff --git a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js index 32e70fec5e16..7d84a91ebd2b 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js +++ b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.js @@ -70,7 +70,7 @@ function IOURequestStepTaxAmountPage({ const textInput = useRef(null); const isEditing = Navigation.getActiveRoute().includes('taxAmount'); - const currency = selectedCurrency || originalCurrency; + const currency = CurrencyUtils.isValidCurrencyCode(selectedCurrency) ? selectedCurrency : originalCurrency; const focusTimeoutRef = useRef(null); From f91b49a6b001338e5386e1fb296060822c614414 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Fri, 29 Mar 2024 10:40:01 +0300 Subject: [PATCH 007/133] changed exitReportID to top most report id --- src/pages/home/report/ReportActionItem.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index fb338075d630..46009a69d4d5 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -481,7 +481,7 @@ function ReportActionItem({ success style={[styles.w100, styles.requestPreviewBox]} text={translate('bankAccount.addBankAccount')} - onPress={() => BankAccounts.openPersonalBankAccountSetupView(linkedReport?.reportID)} + onPress={() => BankAccounts.openPersonalBankAccountSetupView(Navigation.getTopmostReportId() ?? linkedReport?.reportID)} pressOnEnter large /> From 388afe1b9c7d12aeae8e3db108aabeb163fb34f9 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 29 Mar 2024 17:19:00 +0700 Subject: [PATCH 008/133] fix create troubleshoot page --- .../simple-illustration__lightbulb.svg | 33 ++++ src/components/Icon/Illustrations.ts | 2 + src/components/Section/index.tsx | 18 +- .../ModalStackNavigators/index.tsx | 1 - .../BaseCentralPaneNavigator.tsx | 1 + .../CENTRAL_PANE_TO_RHP_MAPPING.ts | 3 +- .../TAB_TO_CENTRAL_PANE_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 8 +- src/libs/Navigation/types.ts | 2 + src/pages/settings/AboutPage/AboutPage.tsx | 5 - .../settings/AboutPage/TroubleshootPage.tsx | 158 --------------- src/pages/settings/InitialSettingsPage.tsx | 5 + .../Troubleshoot/TroubleshootPage.tsx | 182 ++++++++++++++++++ 13 files changed, 245 insertions(+), 174 deletions(-) create mode 100644 assets/images/simple-illustrations/simple-illustration__lightbulb.svg delete mode 100644 src/pages/settings/AboutPage/TroubleshootPage.tsx create mode 100644 src/pages/settings/Troubleshoot/TroubleshootPage.tsx diff --git a/assets/images/simple-illustrations/simple-illustration__lightbulb.svg b/assets/images/simple-illustrations/simple-illustration__lightbulb.svg new file mode 100644 index 000000000000..1dc359764147 --- /dev/null +++ b/assets/images/simple-illustrations/simple-illustration__lightbulb.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/components/Icon/Illustrations.ts b/src/components/Icon/Illustrations.ts index 28d1d53ed60c..3637ce3d2150 100644 --- a/src/components/Icon/Illustrations.ts +++ b/src/components/Icon/Illustrations.ts @@ -52,6 +52,7 @@ import HotDogStand from '@assets/images/simple-illustrations/simple-illustration import Hourglass from '@assets/images/simple-illustrations/simple-illustration__hourglass.svg'; import House from '@assets/images/simple-illustrations/simple-illustration__house.svg'; import InvoiceBlue from '@assets/images/simple-illustrations/simple-illustration__invoice.svg'; +import Lightbulb from '@assets/images/simple-illustrations/simple-illustration__lightbulb.svg'; import LockClosed from '@assets/images/simple-illustrations/simple-illustration__lockclosed.svg'; import LockOpen from '@assets/images/simple-illustrations/simple-illustration__lockopen.svg'; import Luggage from '@assets/images/simple-illustrations/simple-illustration__luggage.svg'; @@ -158,4 +159,5 @@ export { Pencil, Tag, CarIce, + Lightbulb, }; diff --git a/src/components/Section/index.tsx b/src/components/Section/index.tsx index 93a2e91639a6..848761c9e982 100644 --- a/src/components/Section/index.tsx +++ b/src/components/Section/index.tsx @@ -70,6 +70,9 @@ type SectionProps = ChildrenProps & { /** Overlay content to display on top of animation */ overlayContent?: () => ReactNode; + + /** The component to display in the title of the section */ + renderSubtitle?: () => ReactNode; }; function Section({ @@ -90,6 +93,7 @@ function Section({ illustrationBackgroundColor, illustrationStyle, overlayContent, + renderSubtitle, }: SectionProps) { const styles = useThemeStyles(); const theme = useTheme(); @@ -139,11 +143,15 @@ function Section({ )} - {!!subtitle && ( - - {subtitle} - - )} + {renderSubtitle + ? renderSubtitle?.() + : !!subtitle && ( + + {subtitle} + + )} {children} diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index ef1fc3c2dfb0..4c57741e19eb 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -198,7 +198,6 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/settings/Preferences/ThemePage').default as React.ComponentType, [SCREENS.SETTINGS.CLOSE]: () => require('../../../../pages/settings/Security/CloseAccountPage').default as React.ComponentType, [SCREENS.SETTINGS.APP_DOWNLOAD_LINKS]: () => require('../../../../pages/settings/AppDownloadLinks').default as React.ComponentType, - [SCREENS.SETTINGS.TROUBLESHOOT]: () => require('../../../../pages/settings/AboutPage/TroubleshootPage').default as React.ComponentType, [SCREENS.SETTINGS.CONSOLE]: () => require('../../../../pages/settings/AboutPage/ConsolePage').default as React.ComponentType, [SCREENS.SETTINGS.SHARE_LOG]: () => require('../../../../pages/settings/AboutPage/ShareLogPage').default as React.ComponentType, [SCREENS.SETTINGS.WALLET.CARDS_DIGITAL_DETAILS_UPDATE_ADDRESS]: () => require('../../../../pages/settings/Profile/PersonalDetails/AddressPage').default as React.ComponentType, diff --git a/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx index 16f403342a58..b13d38570cd7 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator/BaseCentralPaneNavigator.tsx @@ -20,6 +20,7 @@ const settingsScreens = { [SCREENS.SETTINGS.PROFILE.ROOT]: () => require('../../../../../pages/settings/Profile/ProfilePage').default as React.ComponentType, [SCREENS.SETTINGS.WALLET.ROOT]: () => require('../../../../../pages/settings/Wallet/WalletPage').default as React.ComponentType, [SCREENS.SETTINGS.ABOUT]: () => require('../../../../../pages/settings/AboutPage/AboutPage').default as React.ComponentType, + [SCREENS.SETTINGS.TROUBLESHOOT]: () => require('../../../../../pages/settings/Troubleshoot/TroubleshootPage').default as React.ComponentType, } satisfies Screens; function BaseCentralPaneNavigator() { diff --git a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts index 95233bfed079..ffac214c154d 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -35,7 +35,8 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial> = SCREENS.SETTINGS.WALLET.CARDS_DIGITAL_DETAILS_UPDATE_ADDRESS, ], [SCREENS.SETTINGS.SECURITY]: [SCREENS.SETTINGS.TWO_FACTOR_AUTH, SCREENS.SETTINGS.CLOSE], - [SCREENS.SETTINGS.ABOUT]: [SCREENS.SETTINGS.APP_DOWNLOAD_LINKS, SCREENS.SETTINGS.TROUBLESHOOT], + [SCREENS.SETTINGS.ABOUT]: [SCREENS.SETTINGS.APP_DOWNLOAD_LINKS], + [SCREENS.SETTINGS.TROUBLESHOOT]: [SCREENS.SETTINGS.CONSOLE], }; export default CENTRAL_PANE_TO_RHP_MAPPING; diff --git a/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts b/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts index 78a644ab4aee..a349a3425e29 100755 --- a/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING.ts @@ -10,6 +10,7 @@ const TAB_TO_CENTRAL_PANE_MAPPING: Record = { SCREENS.SETTINGS.WALLET.ROOT, SCREENS.SETTINGS.ABOUT, SCREENS.SETTINGS.WORKSPACES, + SCREENS.SETTINGS.TROUBLESHOOT, ], }; diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index c9c5d47a2df3..cd4fd463820f 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -60,6 +60,10 @@ const config: LinkingOptions['config'] = { path: ROUTES.SETTINGS_ABOUT, exact: true, }, + [SCREENS.SETTINGS.TROUBLESHOOT]: { + path: ROUTES.SETTINGS_TROUBLESHOOT, + exact: true, + }, [SCREENS.SETTINGS.WORKSPACES]: ROUTES.SETTINGS_WORKSPACES, }, }, @@ -176,10 +180,6 @@ const config: LinkingOptions['config'] = { path: ROUTES.SETTINGS_APP_DOWNLOAD_LINKS, exact: true, }, - [SCREENS.SETTINGS.TROUBLESHOOT]: { - path: ROUTES.SETTINGS_TROUBLESHOOT, - exact: true, - }, [SCREENS.SETTINGS.CONSOLE]: { path: ROUTES.SETTINGS_CONSOLE, exact: true, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 60b2ed63ab49..d1d5e788dc26 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -58,6 +58,7 @@ type CentralPaneNavigatorParamList = { [SCREENS.SETTINGS.SECURITY]: undefined; [SCREENS.SETTINGS.WALLET.ROOT]: undefined; [SCREENS.SETTINGS.ABOUT]: undefined; + [SCREENS.SETTINGS.TROUBLESHOOT]: undefined; [SCREENS.SETTINGS.WORKSPACES]: undefined; }; @@ -102,6 +103,7 @@ type SettingsNavigatorParamList = { [SCREENS.SETTINGS.CLOSE]: undefined; [SCREENS.SETTINGS.SECURITY]: undefined; [SCREENS.SETTINGS.ABOUT]: undefined; + [SCREENS.SETTINGS.TROUBLESHOOT]: undefined; [SCREENS.SETTINGS.APP_DOWNLOAD_LINKS]: undefined; [SCREENS.SETTINGS.TROUBLESHOOT]: undefined; [SCREENS.SETTINGS.CONSOLE]: undefined; diff --git a/src/pages/settings/AboutPage/AboutPage.tsx b/src/pages/settings/AboutPage/AboutPage.tsx index 0c087b2c93d6..56336386c46b 100644 --- a/src/pages/settings/AboutPage/AboutPage.tsx +++ b/src/pages/settings/AboutPage/AboutPage.tsx @@ -87,11 +87,6 @@ function AboutPage() { }, link: CONST.UPWORK_URL, }, - { - translationKey: 'initialSettingsPage.aboutPage.troubleshoot', - icon: Expensicons.Lightbulb, - action: waitForNavigate(() => Navigation.navigate(ROUTES.SETTINGS_TROUBLESHOOT)), - }, { translationKey: 'initialSettingsPage.aboutPage.reportABug', icon: Expensicons.Bug, diff --git a/src/pages/settings/AboutPage/TroubleshootPage.tsx b/src/pages/settings/AboutPage/TroubleshootPage.tsx deleted file mode 100644 index e04a834c6341..000000000000 --- a/src/pages/settings/AboutPage/TroubleshootPage.tsx +++ /dev/null @@ -1,158 +0,0 @@ -import React, {useMemo, useState} from 'react'; -import {View} from 'react-native'; -import Onyx, {withOnyx} from 'react-native-onyx'; -import type {OnyxEntry} from 'react-native-onyx'; -import type {SvgProps} from 'react-native-svg'; -import ConfirmModal from '@components/ConfirmModal'; -import * as Expensicons from '@components/Icon/Expensicons'; -import IllustratedHeaderPageLayout from '@components/IllustratedHeaderPageLayout'; -import LottieAnimations from '@components/LottieAnimations'; -import MenuItemList from '@components/MenuItemList'; -import Switch from '@components/Switch'; -import TestToolMenu from '@components/TestToolMenu'; -import TestToolRow from '@components/TestToolRow'; -import Text from '@components/Text'; -import TextLink from '@components/TextLink'; -import useEnvironment from '@hooks/useEnvironment'; -import useLocalize from '@hooks/useLocalize'; -import useTheme from '@hooks/useTheme'; -import useThemeStyles from '@hooks/useThemeStyles'; -import useWaitForNavigation from '@hooks/useWaitForNavigation'; -import * as Console from '@libs/actions/Console'; -import Navigation from '@libs/Navigation/Navigation'; -import * as App from '@userActions/App'; -import * as Report from '@userActions/Report'; -import type {TranslationPaths} from '@src/languages/types'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type {OnyxKey} from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; -import SCREENS from '@src/SCREENS'; - -const keysToPreserve: OnyxKey[] = [ - ONYXKEYS.ACCOUNT, - ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, - ONYXKEYS.IS_LOADING_APP, - ONYXKEYS.IS_SIDEBAR_LOADED, - ONYXKEYS.MODAL, - ONYXKEYS.NETWORK, - ONYXKEYS.SESSION, - ONYXKEYS.SHOULD_SHOW_COMPOSE_INPUT, - ONYXKEYS.NVP_TRY_FOCUS_MODE, - ONYXKEYS.PREFERRED_THEME, - ONYXKEYS.NVP_PREFERRED_LOCALE, - ONYXKEYS.CREDENTIALS, -]; - -type BaseMenuItem = { - translationKey: TranslationPaths; - icon: React.FC; - action: () => void | Promise; -}; - -type TroubleshootPageOnyxProps = { - shouldStoreLogs: OnyxEntry; -}; - -type TroubleshootPageProps = TroubleshootPageOnyxProps; - -function TroubleshootPage({shouldStoreLogs}: TroubleshootPageProps) { - const {translate} = useLocalize(); - const theme = useTheme(); - const styles = useThemeStyles(); - const {isProduction} = useEnvironment(); - const [isConfirmationModalVisible, setIsConfirmationModalVisible] = useState(false); - const waitForNavigate = useWaitForNavigation(); - - const menuItems = useMemo(() => { - const debugConsoleItem: BaseMenuItem = { - translationKey: 'initialSettingsPage.troubleshoot.viewConsole', - icon: Expensicons.Gear, - action: waitForNavigate(() => Navigation.navigate(ROUTES.SETTINGS_CONSOLE)), - }; - - const baseMenuItems: BaseMenuItem[] = [ - { - translationKey: 'initialSettingsPage.troubleshoot.clearCacheAndRestart', - icon: Expensicons.RotateLeft, - action: () => setIsConfirmationModalVisible(true), - }, - ]; - - if (shouldStoreLogs) { - baseMenuItems.push(debugConsoleItem); - } - - return baseMenuItems - .map((item) => ({ - key: item.translationKey, - title: translate(item.translationKey), - icon: item.icon, - onPress: item.action, - })) - .reverse(); - }, [shouldStoreLogs, translate, waitForNavigate]); - - return ( - Navigation.goBack()} - backgroundColor={theme.PAGE_THEMES[SCREENS.SETTINGS.TROUBLESHOOT].backgroundColor} - illustration={LottieAnimations.Desk} - testID={TroubleshootPage.displayName} - > - - {translate('initialSettingsPage.aboutPage.troubleshoot')} - - {translate('initialSettingsPage.troubleshoot.description')}{' '} - Report.navigateToConciergeChat()} - > - {translate('initialSettingsPage.troubleshoot.submitBug')} - - - - - - (shouldStoreLogs ? Console.disableLoggingAndFlushLogs() : Console.setShouldStoreLogs(true))} - /> - - - - {/* Enable additional test features in non-production environments */} - {!isProduction && ( - - - - )} - { - setIsConfirmationModalVisible(false); - Onyx.clear(keysToPreserve).then(() => { - App.openApp(); - }); - }} - onCancel={() => setIsConfirmationModalVisible(false)} - prompt={translate('initialSettingsPage.troubleshoot.confirmResetDescription')} - confirmText={translate('initialSettingsPage.troubleshoot.resetAndRefresh')} - cancelText={translate('common.cancel')} - /> - - ); -} - -TroubleshootPage.displayName = 'TroubleshootPage'; - -export default withOnyx({ - shouldStoreLogs: { - key: ONYXKEYS.SHOULD_STORE_LOGS, - }, -})(TroubleshootPage); diff --git a/src/pages/settings/InitialSettingsPage.tsx b/src/pages/settings/InitialSettingsPage.tsx index 73bd031b5978..4cf97c940bfd 100755 --- a/src/pages/settings/InitialSettingsPage.tsx +++ b/src/pages/settings/InitialSettingsPage.tsx @@ -250,6 +250,11 @@ function InitialSettingsPage({session, userWallet, bankAccountList, fundList, wa icon: Expensicons.Info, routeName: ROUTES.SETTINGS_ABOUT, }, + { + translationKey: 'initialSettingsPage.aboutPage.troubleshoot', + icon: Expensicons.Lightbulb, + routeName: ROUTES.SETTINGS_TROUBLESHOOT, + }, { translationKey: signOutTranslationKey, icon: Expensicons.Exit, diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx new file mode 100644 index 000000000000..e2deb70da250 --- /dev/null +++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx @@ -0,0 +1,182 @@ +import React, {useMemo, useState} from 'react'; +import {View} from 'react-native'; +import Onyx, {withOnyx} from 'react-native-onyx'; +import type {OnyxEntry} from 'react-native-onyx'; +import type {SvgProps} from 'react-native-svg'; +import ConfirmModal from '@components/ConfirmModal'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import * as Expensicons from '@components/Icon/Expensicons'; +import * as Illustrations from '@components/Icon/Illustrations'; +import LottieAnimations from '@components/LottieAnimations'; +import MenuItemList from '@components/MenuItemList'; +import ScreenWrapper from '@components/ScreenWrapper'; +import ScrollView from '@components/ScrollView'; +import Section from '@components/Section'; +import Switch from '@components/Switch'; +import TestToolMenu from '@components/TestToolMenu'; +import TestToolRow from '@components/TestToolRow'; +import Text from '@components/Text'; +import TextLink from '@components/TextLink'; +import useEnvironment from '@hooks/useEnvironment'; +import useLocalize from '@hooks/useLocalize'; +import useTheme from '@hooks/useTheme'; +import useThemeStyles from '@hooks/useThemeStyles'; +import useWaitForNavigation from '@hooks/useWaitForNavigation'; +import useWindowDimensions from '@hooks/useWindowDimensions'; +import * as Console from '@libs/actions/Console'; +import Navigation from '@libs/Navigation/Navigation'; +import * as App from '@userActions/App'; +import * as Report from '@userActions/Report'; +import type {TranslationPaths} from '@src/languages/types'; +import ONYXKEYS from '@src/ONYXKEYS'; +import type {OnyxKey} from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; +import SCREENS from '@src/SCREENS'; + +const keysToPreserve: OnyxKey[] = [ + ONYXKEYS.ACCOUNT, + ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, + ONYXKEYS.IS_LOADING_APP, + ONYXKEYS.IS_SIDEBAR_LOADED, + ONYXKEYS.MODAL, + ONYXKEYS.NETWORK, + ONYXKEYS.SESSION, + ONYXKEYS.SHOULD_SHOW_COMPOSE_INPUT, + ONYXKEYS.NVP_TRY_FOCUS_MODE, + ONYXKEYS.PREFERRED_THEME, + ONYXKEYS.NVP_PREFERRED_LOCALE, + ONYXKEYS.CREDENTIALS, +]; + +type BaseMenuItem = { + translationKey: TranslationPaths; + icon: React.FC; + action: () => void | Promise; +}; + +type TroubleshootPageOnyxProps = { + shouldStoreLogs: OnyxEntry; +}; + +type TroubleshootPageProps = TroubleshootPageOnyxProps; + +function TroubleshootPage({shouldStoreLogs}: TroubleshootPageProps) { + const {translate} = useLocalize(); + const theme = useTheme(); + const styles = useThemeStyles(); + const {isProduction} = useEnvironment(); + const [isConfirmationModalVisible, setIsConfirmationModalVisible] = useState(false); + const waitForNavigate = useWaitForNavigation(); + const {isSmallScreenWidth} = useWindowDimensions(); + + const menuItems = useMemo(() => { + const debugConsoleItem: BaseMenuItem = { + translationKey: 'initialSettingsPage.troubleshoot.viewConsole', + icon: Expensicons.Gear, + action: waitForNavigate(() => Navigation.navigate(ROUTES.SETTINGS_CONSOLE)), + }; + + const baseMenuItems: BaseMenuItem[] = [ + { + translationKey: 'initialSettingsPage.troubleshoot.clearCacheAndRestart', + icon: Expensicons.RotateLeft, + action: () => setIsConfirmationModalVisible(true), + }, + ]; + + if (shouldStoreLogs) { + baseMenuItems.push(debugConsoleItem); + } + + return baseMenuItems + .map((item) => ({ + key: item.translationKey, + title: translate(item.translationKey), + icon: item.icon, + onPress: item.action, + })) + .reverse(); + }, [shouldStoreLogs, translate, waitForNavigate]); + + return ( + + Navigation.goBack(ROUTES.SETTINGS)} + icon={Illustrations.Lightbulb} + /> + + +
( + + {translate('initialSettingsPage.troubleshoot.description')}{' '} + Report.navigateToConciergeChat()} + > + {translate('initialSettingsPage.troubleshoot.submitBug')} + + + )} + > + + + + (shouldStoreLogs ? Console.disableLoggingAndFlushLogs() : Console.setShouldStoreLogs(true))} + /> + + + + {!isProduction && ( + + + + )} + { + setIsConfirmationModalVisible(false); + Onyx.clear(keysToPreserve).then(() => { + App.openApp(); + }); + }} + onCancel={() => setIsConfirmationModalVisible(false)} + prompt={translate('initialSettingsPage.troubleshoot.confirmResetDescription')} + confirmText={translate('initialSettingsPage.troubleshoot.resetAndRefresh')} + cancelText={translate('common.cancel')} + /> + +
+
+
+
+ ); +} + +TroubleshootPage.displayName = 'TroubleshootPage'; + +export default withOnyx({ + shouldStoreLogs: { + key: ONYXKEYS.SHOULD_STORE_LOGS, + }, +})(TroubleshootPage); From 465db73c5d620fc12c68dcfb7a38d62405d9c1a5 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 29 Mar 2024 18:28:52 +0700 Subject: [PATCH 009/133] fix margin right issue --- src/pages/settings/Troubleshoot/TroubleshootPage.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx index e2deb70da250..379615b171d9 100644 --- a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx +++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx @@ -129,11 +129,12 @@ function TroubleshootPage({shouldStoreLogs}: TroubleshootPageProps) { > {translate('initialSettingsPage.troubleshoot.submitBug')} + . )} > - + {!isProduction && ( - + )} From 5750264acae685f6744ac991b0e818961d41fe00 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Sat, 30 Mar 2024 16:30:18 +0700 Subject: [PATCH 010/133] update welcome note --- src/languages/en.ts | 10 ++----- src/languages/es.ts | 10 ++----- src/languages/types.ts | 2 +- .../workspace/WorkspaceInviteMessagePage.tsx | 26 +++++++++++++------ 4 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index f83d78ac14e9..7c4eb6e3328b 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2048,14 +2048,8 @@ export default { personalMessagePrompt: 'Message', genericFailureMessage: 'An error occurred inviting the user to the workspace, please try again.', inviteNoMembersError: 'Please select at least one member to invite', - welcomeNote: ({workspaceName, senderDisplayName, senderLogin, workspaceDescription, workspaceLink}: WelcomeNoteParams) => `${ - senderDisplayName ? `#${senderDisplayName} (${senderLogin}) invited you to Expensify` : `#${senderLogin} invited you to Expensify` - }\nHi there 1 -\n\nTo join "${workspaceName}", [click here](${workspaceLink}) to start tracking your expenses!\n\nThey also added the message:\nYou have been invited to ${ - workspaceName || 'a workspace' - }! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.\n\n${ - workspaceDescription ? `Additionally, here is the workspace description:\n ${workspaceDescription}` : '' - } - `, + welcomeNote: ({workspaceName, senderDisplayName, senderLogin, inviteMessage}: WelcomeNoteParams) => + `${`${senderDisplayName !== senderLogin ? `${senderDisplayName} (${senderLogin})` : senderLogin} invited you to ${workspaceName}`}\n\n${inviteMessage}`, }, distanceRates: { oopsNotSoFast: 'Oops! Not so fast...', diff --git a/src/languages/es.ts b/src/languages/es.ts index ac6ef2f3f9b7..3849999be62a 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2076,14 +2076,8 @@ export default { personalMessagePrompt: 'Mensaje', inviteNoMembersError: 'Por favor, selecciona al menos un miembro a invitar', genericFailureMessage: 'Se produjo un error al invitar al usuario al espacio de trabajo. Vuelva a intentarlo..', - welcomeNote: ({workspaceName, senderDisplayName, senderLogin, workspaceDescription, workspaceLink}: WelcomeNoteParams) => `${ - senderDisplayName ? `#${senderDisplayName} (${senderLogin}) te invitó a Expensify` : `#${senderLogin} te invitó a Expensify` - }\n¡Hola! -\n\nPara unirte a "${workspaceName}", [haz clic aquí](${workspaceLink}) para empezar a seguir tus gastos!\n\nTambién añadieron el mensaje:\nHas sido invitado a ${ - workspaceName || 'un espacio de trabajo' - }! Descarga la aplicación móvil de Expensify en use.expensify.com/download para empezar a seguir tus gastos.\n\n${ - workspaceDescription ? `Además, aquí está la descripción del espacio de trabajo:\n ${workspaceDescription}` : '' - } - `, + welcomeNote: ({workspaceName, senderDisplayName, senderLogin, inviteMessage}: WelcomeNoteParams) => + `${`${senderDisplayName !== senderLogin ? `${senderDisplayName} (${senderLogin})` : senderLogin} te invitó a ${workspaceName}`}\n\n${inviteMessage}`, }, distanceRates: { oopsNotSoFast: 'Ups! No tan rápido...', diff --git a/src/languages/types.ts b/src/languages/types.ts index df40a8d25425..98ef55f58587 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -185,7 +185,7 @@ type UserIsAlreadyMemberParams = {login: string; name: string}; type GoToRoomParams = {roomName: string}; -type WelcomeNoteParams = {workspaceName: string; senderDisplayName: string; senderLogin: string; workspaceDescription: string; workspaceLink: string}; +type WelcomeNoteParams = {workspaceName: string; senderDisplayName?: string; senderLogin?: string; inviteMessage?: string}; type RoomNameReservedErrorParams = {reservedName: string}; diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.tsx b/src/pages/workspace/WorkspaceInviteMessagePage.tsx index 99c7f4dd41a8..8b4ecdf31887 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx +++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx @@ -76,13 +76,14 @@ function WorkspaceInviteMessagePage({ // workspaceInviteMessageDraft can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing workspaceInviteMessageDraft || - translate('workspace.inviteMessage.welcomeNote', { - workspaceName: policy?.name ?? '', - senderDisplayName: currentUserPersonalDetails?.displayName ?? '', - senderLogin: currentUserPersonalDetails?.login ?? '', - workspaceDescription: parser.htmlToMarkdown(policy?.description ?? ''), - workspaceLink: ROUTES.WORKSPACE_PROFILE.getRoute(route.params.policyID), - }); + // policy?.description can be an empty string + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + policy?.description || + parser.replace( + translate('workspace.common.welcomeNote', { + workspaceName: policy?.name ?? '', + }), + ); useEffect(() => { if (!isEmptyObject(invitedEmailsToAccountIDsDraft)) { @@ -100,7 +101,16 @@ function WorkspaceInviteMessagePage({ const sendInvitation = () => { Keyboard.dismiss(); // Please see https://github.com/Expensify/App/blob/main/README.md#Security for more details - Policy.addMembersToWorkspace(invitedEmailsToAccountIDsDraft ?? {}, welcomeNote ?? '', route.params.policyID); + Policy.addMembersToWorkspace( + invitedEmailsToAccountIDsDraft ?? {}, + translate('workspace.inviteMessage.welcomeNote', { + workspaceName: policy?.name ?? '', + senderDisplayName: currentUserPersonalDetails?.displayName ?? '', + senderLogin: currentUserPersonalDetails?.login ?? '', + inviteMessage: welcomeNote, + }), + route.params.policyID, + ); debouncedSaveDraft(null); SearchInputManager.searchInput = ''; // Pop the invite message page before navigating to the members page. From 2d84c3d6cefc9f102feab16dacde13eda284062e Mon Sep 17 00:00:00 2001 From: tienifr Date: Mon, 1 Apr 2024 17:42:01 +0700 Subject: [PATCH 011/133] fix unsubscribe is typing event if not focus on screen --- src/pages/home/report/ReportActionsList.tsx | 3 -- src/pages/home/report/ReportActionsView.tsx | 42 ++++++++++++++------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index d1b9c420b0af..ebe12143903e 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -351,9 +351,6 @@ function ReportActionsList({ if (unsubscribe) { unsubscribe(); } - InteractionManager.runAfterInteractions(() => { - Report.unsubscribeFromReportChannel(report.reportID); - }); }; newActionUnsubscribeMap[report.reportID] = cleanup; diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 1b6a9614a466..e8f7f77f7c05 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -12,6 +12,7 @@ import usePrevious from '@hooks/usePrevious'; import useWindowDimensions from '@hooks/useWindowDimensions'; import DateUtils from '@libs/DateUtils'; import getIsReportFullyVisible from '@libs/getIsReportFullyVisible'; +import Navigation from '@libs/Navigation/Navigation'; import type {CentralPaneNavigatorParamList} from '@libs/Navigation/types'; import * as NumberUtils from '@libs/NumberUtils'; import {generateNewRandomInt} from '@libs/NumberUtils'; @@ -324,21 +325,34 @@ function ReportActionsView({ if (route?.params?.reportID !== reportID) { return; } - // Ensures subscription event succeeds when the report/workspace room is created optimistically. - // Check if the optimistic `OpenReport` or `AddWorkspaceRoom` has succeeded by confirming - // any `pendingFields.createChat` or `pendingFields.addWorkspaceRoom` fields are set to null. - // Existing reports created will have empty fields for `pendingFields`. - const didCreateReportSuccessfully = !report.pendingFields || (!report.pendingFields.addWorkspaceRoom && !report.pendingFields.createChat); - if (!didSubscribeToReportTypingEvents.current && didCreateReportSuccessfully) { - const interactionTask = InteractionManager.runAfterInteractions(() => { - Report.subscribeToReportTypingEvents(reportID); - didSubscribeToReportTypingEvents.current = true; - }); - return () => { - interactionTask.cancel(); - }; + + if (isFocused) { + // Ensures subscription event succeeds when the report/workspace room is created optimistically. + // Check if the optimistic `OpenReport` or `AddWorkspaceRoom` has succeeded by confirming + // any `pendingFields.createChat` or `pendingFields.addWorkspaceRoom` fields are set to null. + // Existing reports created will have empty fields for `pendingFields`. + const didCreateReportSuccessfully = !report.pendingFields || (!report.pendingFields.addWorkspaceRoom && !report.pendingFields.createChat); + + if (!didSubscribeToReportTypingEvents.current && didCreateReportSuccessfully) { + const interactionTask = InteractionManager.runAfterInteractions(() => { + Report.subscribeToReportTypingEvents(reportID); + didSubscribeToReportTypingEvents.current = true; + }); + return () => { + interactionTask.cancel(); + }; + } + } else { + const topmostReportId = Navigation.getTopmostReportId(); + + if (topmostReportId !== report.reportID && didSubscribeToReportTypingEvents.current) { + didSubscribeToReportTypingEvents.current = false; + InteractionManager.runAfterInteractions(() => { + Report.unsubscribeFromReportChannel(report.reportID); + }); + } } - }, [report.pendingFields, didSubscribeToReportTypingEvents, route, reportID]); + }, [isFocused, report.reportID, report.pendingFields, didSubscribeToReportTypingEvents, route, reportID]); const onContentSizeChange = useCallback((w: number, h: number) => { contentListHeight.current = h; From 72287935975b1316e55b537b62869ed8aa6f5151 Mon Sep 17 00:00:00 2001 From: tienifr Date: Mon, 1 Apr 2024 18:03:27 +0700 Subject: [PATCH 012/133] fix lint --- src/pages/home/report/ReportActionsList.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index ebe12143903e..ee32c3c2ff61 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -348,9 +348,10 @@ function ReportActionsList({ const unsubscribe = Report.subscribeToNewActionEvent(report.reportID, scrollToBottomForCurrentUserAction); const cleanup = () => { - if (unsubscribe) { - unsubscribe(); + if (!unsubscribe) { + return; } + unsubscribe(); }; newActionUnsubscribeMap[report.reportID] = cleanup; From a1fe399a89167c26ef64ae1a1527001684995775 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 2 Apr 2024 13:02:05 +0700 Subject: [PATCH 013/133] update default welcome note --- src/languages/en.ts | 2 - src/languages/es.ts | 2 - src/languages/types.ts | 2 +- .../workspace/WorkspaceInviteMessagePage.tsx | 53 +++++++------------ src/types/onyx/Policy.ts | 5 ++ 5 files changed, 24 insertions(+), 40 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 28854ca4d0f4..fd2daa50942f 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2054,8 +2054,6 @@ export default { personalMessagePrompt: 'Message', genericFailureMessage: 'An error occurred inviting the user to the workspace, please try again.', inviteNoMembersError: 'Please select at least one member to invite', - welcomeNote: ({workspaceName, senderDisplayName, senderLogin, inviteMessage}: WelcomeNoteParams) => - `${`${senderDisplayName !== senderLogin ? `${senderDisplayName} (${senderLogin})` : senderLogin} invited you to ${workspaceName}`}\n\n${inviteMessage}`, }, distanceRates: { oopsNotSoFast: 'Oops! Not so fast...', diff --git a/src/languages/es.ts b/src/languages/es.ts index acbe8dc064ce..1482ad5e0c5c 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2082,8 +2082,6 @@ export default { personalMessagePrompt: 'Mensaje', inviteNoMembersError: 'Por favor, selecciona al menos un miembro a invitar', genericFailureMessage: 'Se produjo un error al invitar al usuario al espacio de trabajo. Vuelva a intentarlo..', - welcomeNote: ({workspaceName, senderDisplayName, senderLogin, inviteMessage}: WelcomeNoteParams) => - `${`${senderDisplayName !== senderLogin ? `${senderDisplayName} (${senderLogin})` : senderLogin} te invitó a ${workspaceName}`}\n\n${inviteMessage}`, }, distanceRates: { oopsNotSoFast: 'Ups! No tan rápido...', diff --git a/src/languages/types.ts b/src/languages/types.ts index 98ef55f58587..c365363f84af 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -185,7 +185,7 @@ type UserIsAlreadyMemberParams = {login: string; name: string}; type GoToRoomParams = {roomName: string}; -type WelcomeNoteParams = {workspaceName: string; senderDisplayName?: string; senderLogin?: string; inviteMessage?: string}; +type WelcomeNoteParams = {workspaceName: string}; type RoomNameReservedErrorParams = {reservedName: string}; diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.tsx b/src/pages/workspace/WorkspaceInviteMessagePage.tsx index 8b4ecdf31887..f060eb7746d1 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx +++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx @@ -17,8 +17,6 @@ import type {AnimatedTextInputRef} from '@components/RNTextInput'; import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; -import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; -import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -53,20 +51,13 @@ type WorkspaceInviteMessagePageOnyxProps = { type WorkspaceInviteMessagePageProps = WithPolicyAndFullscreenLoadingProps & WorkspaceInviteMessagePageOnyxProps & - WithCurrentUserPersonalDetailsProps & StackScreenProps; -function WorkspaceInviteMessagePage({ - workspaceInviteMessageDraft, - invitedEmailsToAccountIDsDraft, - policy, - route, - allPersonalDetails, - currentUserPersonalDetails, -}: WorkspaceInviteMessagePageProps) { +const parser = new ExpensiMark(); + +function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsToAccountIDsDraft, policy, route, allPersonalDetails}: WorkspaceInviteMessagePageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const parser = new ExpensiMark(); const [welcomeNote, setWelcomeNote] = useState(); @@ -76,6 +67,9 @@ function WorkspaceInviteMessagePage({ // workspaceInviteMessageDraft can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing workspaceInviteMessageDraft || + // policy?.welcomeNote?.user can be an empty string + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + policy?.welcomeNote?.user || // policy?.description can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing policy?.description || @@ -101,16 +95,7 @@ function WorkspaceInviteMessagePage({ const sendInvitation = () => { Keyboard.dismiss(); // Please see https://github.com/Expensify/App/blob/main/README.md#Security for more details - Policy.addMembersToWorkspace( - invitedEmailsToAccountIDsDraft ?? {}, - translate('workspace.inviteMessage.welcomeNote', { - workspaceName: policy?.name ?? '', - senderDisplayName: currentUserPersonalDetails?.displayName ?? '', - senderLogin: currentUserPersonalDetails?.login ?? '', - inviteMessage: welcomeNote, - }), - route.params.policyID, - ); + Policy.addMembersToWorkspace(invitedEmailsToAccountIDsDraft ?? {}, welcomeNote ?? '', route.params.policyID); debouncedSaveDraft(null); SearchInputManager.searchInput = ''; // Pop the invite message page before navigating to the members page. @@ -226,17 +211,15 @@ function WorkspaceInviteMessagePage({ WorkspaceInviteMessagePage.displayName = 'WorkspaceInviteMessagePage'; export default withPolicyAndFullscreenLoading( - withCurrentUserPersonalDetails( - withOnyx({ - allPersonalDetails: { - key: ONYXKEYS.PERSONAL_DETAILS_LIST, - }, - invitedEmailsToAccountIDsDraft: { - key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`, - }, - workspaceInviteMessageDraft: { - key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${route.params.policyID.toString()}`, - }, - })(WorkspaceInviteMessagePage), - ), + withOnyx({ + allPersonalDetails: { + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + }, + invitedEmailsToAccountIDsDraft: { + key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`, + }, + workspaceInviteMessageDraft: { + key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${route.params.policyID.toString()}`, + }, + })(WorkspaceInviteMessagePage), ); diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index ddb0c33c2f0c..84d6e217835a 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -438,6 +438,11 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< /** Indicates if the Policy ownership change is failed */ isChangeOwnerFailed?: boolean; + + /** The welcomeNote of user */ + welcomeNote?: { + user: string; + }; } & Partial, 'generalSettings' | 'addWorkspaceRoom' >; From 394ea6a03fe78c82946a4cb46cc49e2e492af894 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 3 Apr 2024 14:01:05 +0700 Subject: [PATCH 014/133] add subject line --- src/languages/en.ts | 4 ++ src/languages/es.ts | 4 ++ src/languages/types.ts | 2 +- src/libs/actions/Policy.ts | 3 +- .../workspace/WorkspaceInviteMessagePage.tsx | 49 +++++++++++++------ 5 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 752d17e37d03..b43656daaa7a 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2060,6 +2060,10 @@ export default { personalMessagePrompt: 'Message', genericFailureMessage: 'An error occurred inviting the user to the workspace, please try again.', inviteNoMembersError: 'Please select at least one member to invite', + welcomeNote: ({inviterDisplayName, workspaceName, inviteMessage}: WelcomeNoteParams) => + `# ${inviterDisplayName} invited you to ${workspaceName || 'a workspace'} + +${inviteMessage}`, }, distanceRates: { oopsNotSoFast: 'Oops! Not so fast...', diff --git a/src/languages/es.ts b/src/languages/es.ts index 53ee6d3fba79..18b7f15d70cf 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2088,6 +2088,10 @@ export default { personalMessagePrompt: 'Mensaje', inviteNoMembersError: 'Por favor, selecciona al menos un miembro a invitar', genericFailureMessage: 'Se produjo un error al invitar al usuario al espacio de trabajo. Vuelva a intentarlo..', + welcomeNote: ({inviterDisplayName, workspaceName, inviteMessage}: WelcomeNoteParams) => + `# ${inviterDisplayName} invited you to ${workspaceName || 'a workspace'} + +${inviteMessage}`, }, distanceRates: { oopsNotSoFast: 'Ups! No tan rápido...', diff --git a/src/languages/types.ts b/src/languages/types.ts index c365363f84af..f64291ff6396 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -185,7 +185,7 @@ type UserIsAlreadyMemberParams = {login: string; name: string}; type GoToRoomParams = {roomName: string}; -type WelcomeNoteParams = {workspaceName: string}; +type WelcomeNoteParams = {workspaceName: string; inviterDisplayName?: string; inviteMessage?: string}; type RoomNameReservedErrorParams = {reservedName: string}; diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index 3c34e823ac9a..79ef142e772c 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -1,5 +1,4 @@ import {PUBLIC_DOMAINS} from 'expensify-common/lib/CONST'; -import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import Str from 'expensify-common/lib/str'; import {escapeRegExp} from 'lodash'; import lodashClone from 'lodash/clone'; @@ -1348,7 +1347,7 @@ function addMembersToWorkspace(invitedEmailsToAccountIDs: InvitedEmailsToAccount const params: AddMembersToWorkspaceParams = { employees: JSON.stringify(logins.map((login) => ({email: login}))), - welcomeNote: new ExpensiMark().replace(welcomeNote), + welcomeNote, policyID, }; if (!isEmptyObject(membersChats.reportCreationData)) { diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.tsx b/src/pages/workspace/WorkspaceInviteMessagePage.tsx index f060eb7746d1..be9859a55899 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx +++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx @@ -17,6 +17,8 @@ import type {AnimatedTextInputRef} from '@components/RNTextInput'; import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; +import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; +import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -50,12 +52,20 @@ type WorkspaceInviteMessagePageOnyxProps = { }; type WorkspaceInviteMessagePageProps = WithPolicyAndFullscreenLoadingProps & + WithCurrentUserPersonalDetailsProps & WorkspaceInviteMessagePageOnyxProps & StackScreenProps; const parser = new ExpensiMark(); -function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsToAccountIDsDraft, policy, route, allPersonalDetails}: WorkspaceInviteMessagePageProps) { +function WorkspaceInviteMessagePage({ + workspaceInviteMessageDraft, + invitedEmailsToAccountIDsDraft, + policy, + route, + allPersonalDetails, + currentUserPersonalDetails, +}: WorkspaceInviteMessagePageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -67,9 +77,6 @@ function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsT // workspaceInviteMessageDraft can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing workspaceInviteMessageDraft || - // policy?.welcomeNote?.user can be an empty string - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - policy?.welcomeNote?.user || // policy?.description can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing policy?.description || @@ -95,7 +102,15 @@ function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsT const sendInvitation = () => { Keyboard.dismiss(); // Please see https://github.com/Expensify/App/blob/main/README.md#Security for more details - Policy.addMembersToWorkspace(invitedEmailsToAccountIDsDraft ?? {}, welcomeNote ?? '', route.params.policyID); + Policy.addMembersToWorkspace( + invitedEmailsToAccountIDsDraft ?? {}, + translate('workspace.inviteMessage.welcomeNote', { + workspaceName: policy?.name ?? '', + inviterDisplayName: currentUserPersonalDetails?.displayName ?? '', + inviteMessage: parser.replace(welcomeNote ?? ''), + }), + route.params.policyID, + ); debouncedSaveDraft(null); SearchInputManager.searchInput = ''; // Pop the invite message page before navigating to the members page. @@ -211,15 +226,17 @@ function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsT WorkspaceInviteMessagePage.displayName = 'WorkspaceInviteMessagePage'; export default withPolicyAndFullscreenLoading( - withOnyx({ - allPersonalDetails: { - key: ONYXKEYS.PERSONAL_DETAILS_LIST, - }, - invitedEmailsToAccountIDsDraft: { - key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`, - }, - workspaceInviteMessageDraft: { - key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${route.params.policyID.toString()}`, - }, - })(WorkspaceInviteMessagePage), + withCurrentUserPersonalDetails( + withOnyx({ + allPersonalDetails: { + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + }, + invitedEmailsToAccountIDsDraft: { + key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`, + }, + workspaceInviteMessageDraft: { + key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${route.params.policyID.toString()}`, + }, + })(WorkspaceInviteMessagePage), + ), ); From 3fe9d34dd677dea2442c2622c8a1f7b26d5af2a1 Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 3 Apr 2024 14:35:15 +0700 Subject: [PATCH 015/133] fix remove unused file --- .../settings/AboutPage/TroubleshootPage.tsx | 150 ------------------ 1 file changed, 150 deletions(-) delete mode 100644 src/pages/settings/AboutPage/TroubleshootPage.tsx diff --git a/src/pages/settings/AboutPage/TroubleshootPage.tsx b/src/pages/settings/AboutPage/TroubleshootPage.tsx deleted file mode 100644 index 0e192540ebd2..000000000000 --- a/src/pages/settings/AboutPage/TroubleshootPage.tsx +++ /dev/null @@ -1,150 +0,0 @@ -import React, {useMemo, useState} from 'react'; -import {View} from 'react-native'; -import Onyx, {withOnyx} from 'react-native-onyx'; -import type {OnyxEntry} from 'react-native-onyx'; -import type {SvgProps} from 'react-native-svg'; -import ClientSideLoggingToolMenu from '@components/ClientSideLoggingToolMenu'; -import ConfirmModal from '@components/ConfirmModal'; -import * as Expensicons from '@components/Icon/Expensicons'; -import IllustratedHeaderPageLayout from '@components/IllustratedHeaderPageLayout'; -import LottieAnimations from '@components/LottieAnimations'; -import MenuItemList from '@components/MenuItemList'; -import TestToolMenu from '@components/TestToolMenu'; -import Text from '@components/Text'; -import TextLink from '@components/TextLink'; -import useEnvironment from '@hooks/useEnvironment'; -import useLocalize from '@hooks/useLocalize'; -import useTheme from '@hooks/useTheme'; -import useThemeStyles from '@hooks/useThemeStyles'; -import useWaitForNavigation from '@hooks/useWaitForNavigation'; -import Navigation from '@libs/Navigation/Navigation'; -import * as App from '@userActions/App'; -import * as Report from '@userActions/Report'; -import type {TranslationPaths} from '@src/languages/types'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type {OnyxKey} from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; -import SCREENS from '@src/SCREENS'; - -const keysToPreserve: OnyxKey[] = [ - ONYXKEYS.ACCOUNT, - ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, - ONYXKEYS.IS_LOADING_APP, - ONYXKEYS.IS_SIDEBAR_LOADED, - ONYXKEYS.MODAL, - ONYXKEYS.NETWORK, - ONYXKEYS.SESSION, - ONYXKEYS.SHOULD_SHOW_COMPOSE_INPUT, - ONYXKEYS.NVP_TRY_FOCUS_MODE, - ONYXKEYS.PREFERRED_THEME, - ONYXKEYS.NVP_PREFERRED_LOCALE, - ONYXKEYS.CREDENTIALS, -]; - -type BaseMenuItem = { - translationKey: TranslationPaths; - icon: React.FC; - action: () => void | Promise; -}; - -type TroubleshootPageOnyxProps = { - shouldStoreLogs: OnyxEntry; -}; - -type TroubleshootPageProps = TroubleshootPageOnyxProps; - -function TroubleshootPage({shouldStoreLogs}: TroubleshootPageProps) { - const {translate} = useLocalize(); - const theme = useTheme(); - const styles = useThemeStyles(); - const {isProduction} = useEnvironment(); - const [isConfirmationModalVisible, setIsConfirmationModalVisible] = useState(false); - const waitForNavigate = useWaitForNavigation(); - - const menuItems = useMemo(() => { - const debugConsoleItem: BaseMenuItem = { - translationKey: 'initialSettingsPage.troubleshoot.viewConsole', - icon: Expensicons.Gear, - action: waitForNavigate(() => Navigation.navigate(ROUTES.SETTINGS_CONSOLE)), - }; - - const baseMenuItems: BaseMenuItem[] = [ - { - translationKey: 'initialSettingsPage.troubleshoot.clearCacheAndRestart', - icon: Expensicons.RotateLeft, - action: () => setIsConfirmationModalVisible(true), - }, - ]; - - if (shouldStoreLogs) { - baseMenuItems.push(debugConsoleItem); - } - - return baseMenuItems - .map((item) => ({ - key: item.translationKey, - title: translate(item.translationKey), - icon: item.icon, - onPress: item.action, - })) - .reverse(); - }, [shouldStoreLogs, translate, waitForNavigate]); - - return ( - Navigation.goBack()} - backgroundColor={theme.PAGE_THEMES[SCREENS.SETTINGS.TROUBLESHOOT].backgroundColor} - illustration={LottieAnimations.Desk} - testID={TroubleshootPage.displayName} - > - - {translate('initialSettingsPage.aboutPage.troubleshoot')} - - {translate('initialSettingsPage.troubleshoot.description')}{' '} - Report.navigateToConciergeChat()} - > - {translate('initialSettingsPage.troubleshoot.submitBug')} - - - - - - - - {/* Enable additional test features in non-production environments */} - {!isProduction && ( - - - - )} - { - setIsConfirmationModalVisible(false); - Onyx.clear(keysToPreserve).then(() => { - App.openApp(); - }); - }} - onCancel={() => setIsConfirmationModalVisible(false)} - prompt={translate('initialSettingsPage.troubleshoot.confirmResetDescription')} - confirmText={translate('initialSettingsPage.troubleshoot.resetAndRefresh')} - cancelText={translate('common.cancel')} - /> - - ); -} - -TroubleshootPage.displayName = 'TroubleshootPage'; - -export default withOnyx({ - shouldStoreLogs: { - key: ONYXKEYS.SHOULD_STORE_LOGS, - }, -})(TroubleshootPage); From 0b8743bd1857fd02d9fa7b13023217161eaee44c Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 3 Apr 2024 14:40:54 +0700 Subject: [PATCH 016/133] fix use ClientSideLoggingToolMenu --- src/pages/settings/Troubleshoot/TroubleshootPage.tsx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx index 379615b171d9..39dfb228d57a 100644 --- a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx +++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx @@ -3,6 +3,7 @@ import {View} from 'react-native'; import Onyx, {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import type {SvgProps} from 'react-native-svg'; +import ClientSideLoggingToolMenu from '@components/ClientSideLoggingToolMenu'; import ConfirmModal from '@components/ConfirmModal'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Expensicons from '@components/Icon/Expensicons'; @@ -12,9 +13,7 @@ import MenuItemList from '@components/MenuItemList'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import Section from '@components/Section'; -import Switch from '@components/Switch'; import TestToolMenu from '@components/TestToolMenu'; -import TestToolRow from '@components/TestToolRow'; import Text from '@components/Text'; import TextLink from '@components/TextLink'; import useEnvironment from '@hooks/useEnvironment'; @@ -23,7 +22,6 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; import useWindowDimensions from '@hooks/useWindowDimensions'; -import * as Console from '@libs/actions/Console'; import Navigation from '@libs/Navigation/Navigation'; import * as App from '@userActions/App'; import * as Report from '@userActions/Report'; @@ -135,13 +133,7 @@ function TroubleshootPage({shouldStoreLogs}: TroubleshootPageProps) { > - - (shouldStoreLogs ? Console.disableLoggingAndFlushLogs() : Console.setShouldStoreLogs(true))} - /> - + Date: Wed, 3 Apr 2024 11:58:35 +0400 Subject: [PATCH 017/133] Fix an inconsistency between the mute status icon in full screen mode and mini player mode --- src/components/VideoPlayer/BaseVideoPlayer.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/VideoPlayer/BaseVideoPlayer.js b/src/components/VideoPlayer/BaseVideoPlayer.js index 7016de3fa86c..dcda27a3a8f6 100644 --- a/src/components/VideoPlayer/BaseVideoPlayer.js +++ b/src/components/VideoPlayer/BaseVideoPlayer.js @@ -8,6 +8,7 @@ import Hoverable from '@components/Hoverable'; import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; import {useFullScreenContext} from '@components/VideoPlayerContexts/FullScreenContext'; import {usePlaybackContext} from '@components/VideoPlayerContexts/PlaybackContext'; +import {useVolumeContext} from '@components/VideoPlayerContexts/VolumeContext'; import VideoPopoverMenu from '@components/VideoPopoverMenu'; import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -73,6 +74,7 @@ function BaseVideoPlayer({ const isCurrentlyURLSet = currentlyPlayingURL === url; const isUploading = _.some(CONST.ATTACHMENT_LOCAL_URL_PREFIX, (prefix) => url.startsWith(prefix)); const videoStateRef = useRef(null); + const {updateVolume} = useVolumeContext(); const togglePlayCurrentVideo = useCallback(() => { videoResumeTryNumber.current = 0; @@ -134,6 +136,15 @@ function BaseVideoPlayer({ const handleFullscreenUpdate = useCallback( (e) => { onFullscreenUpdate(e); + + if (e.fullscreenUpdate === VideoFullscreenUpdate.PLAYER_DID_DISMISS) { + currentVideoPlayerRef.current.getStatusAsync().then((status) => { + if (status.volume === 0 || status.isMuted === true) { + updateVolume(0); + } + }); + } + // fix for iOS native and mWeb: when switching to fullscreen and then exiting // the fullscreen mode while playing, the video pauses if (e.fullscreenUpdate === VideoFullscreenUpdate.PLAYER_DID_DISMISS) { From d8880fefb8af1a04888df18d2dce9375792b40b1 Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 3 Apr 2024 17:28:50 +0700 Subject: [PATCH 018/133] fix add translations --- src/components/TestToolMenu.tsx | 18 ++++++++++-------- src/languages/en.ts | 8 ++++++++ src/languages/es.ts | 10 +++++++++- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/components/TestToolMenu.tsx b/src/components/TestToolMenu.tsx index 647f25c450e5..ebfbeffd68df 100644 --- a/src/components/TestToolMenu.tsx +++ b/src/components/TestToolMenu.tsx @@ -1,6 +1,7 @@ import React from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; +import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ApiUtils from '@libs/ApiUtils'; import compose from '@libs/compose'; @@ -30,6 +31,7 @@ const USER_DEFAULT: UserOnyx = {shouldUseStagingServer: undefined, isSubscribedT function TestToolMenu({user = USER_DEFAULT, network}: TestToolMenuProps) { const shouldUseStagingServer = user?.shouldUseStagingServer ?? ApiUtils.isUsingStagingApi(); const styles = useThemeStyles(); + const {translate} = useLocalize(); return ( <> @@ -37,13 +39,13 @@ function TestToolMenu({user = USER_DEFAULT, network}: TestToolMenuProps) { style={[styles.textLabelSupporting, styles.mb4]} numberOfLines={1} > - Test Preferences + {translate('initialSettingsPage.troubleshoot.testingPreferences')} {/* Option to switch between staging and default api endpoints. This enables QA, internal testers and external devs to take advantage of sandbox environments for 3rd party services like Plaid and Onfido. This toggle is not rendered for internal devs as they make environment changes directly to the .env file. */} {!CONFIG.IS_USING_LOCAL_WEB && ( - + + {/* When toggled all network requests will fail. */} - + {/* Instantly invalidates a user's local authToken. Useful for testing flows related to reauthentication. */} - +