From 5ec6b15e5c9a173d0277472a69973954a00662f1 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 24 Nov 2023 12:46:53 -0700 Subject: [PATCH 1/2] revert 29790 --- src/CONST.ts | 1 - src/components/DotIndicatorMessage.tsx | 50 +++++--------------------- src/components/MessagesRow.js | 4 +-- src/languages/en.ts | 3 -- src/languages/es.ts | 3 -- src/libs/ErrorUtils.ts | 10 +----- src/libs/Localize/index.ts | 1 + src/libs/actions/IOU.js | 24 ++++--------- 8 files changed, 17 insertions(+), 79 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index f1364ebbb5bf..346c4969f974 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1154,7 +1154,6 @@ const CONST = { DOCX: 'docx', SVG: 'svg', }, - RECEIPT_ERROR: 'receiptError', }, GROWL: { diff --git a/src/components/DotIndicatorMessage.tsx b/src/components/DotIndicatorMessage.tsx index 112feab166cf..c134f0019a49 100644 --- a/src/components/DotIndicatorMessage.tsx +++ b/src/components/DotIndicatorMessage.tsx @@ -1,19 +1,14 @@ /* eslint-disable react/no-array-index-key */ import React from 'react'; import {StyleProp, TextStyle, View, ViewStyle} from 'react-native'; -import fileDownload from '@libs/fileDownload'; import * as Localize from '@libs/Localize'; import * as StyleUtils from '@styles/StyleUtils'; import useTheme from '@styles/themes/useTheme'; import useThemeStyles from '@styles/useThemeStyles'; -import CONST from '@src/CONST'; import Icon from './Icon'; import * as Expensicons from './Icon/Expensicons'; -import {PressableWithoutFeedback} from './Pressable'; import Text from './Text'; -type ReceiptError = {error?: string; source: string; filename: string}; - type DotIndicatorMessageProps = { /** * In most cases this should just be errors from onxyData @@ -34,14 +29,6 @@ type DotIndicatorMessageProps = { textStyles?: StyleProp; }; -/** Check if the error includes a receipt. */ -function isReceiptError(message: string | ReceiptError): message is ReceiptError { - if (typeof message === 'string') { - return false; - } - return (message?.error ?? '') === CONST.IOU.RECEIPT_ERROR; -} - function DotIndicatorMessage({messages = {}, style, type, textStyles}: DotIndicatorMessageProps) { const theme = useTheme(); const styles = useThemeStyles(); @@ -69,35 +56,14 @@ function DotIndicatorMessage({messages = {}, style, type, textStyles}: DotIndica /> - {uniqueMessages.map((message, i) => - isReceiptError(message) ? ( - { - fileDownload(message.source, message.filename); - }} - > - - {Localize.translateLocal('iou.error.receiptFailureMessage')} - {Localize.translateLocal('iou.error.saveFileMessage')} - {Localize.translateLocal('iou.error.loseFileMessage')} - - - ) : ( - - {message} - - ), - )} + {uniqueMessages.map((message, i) => ( + + {message} + + ))} ); diff --git a/src/components/MessagesRow.js b/src/components/MessagesRow.js index e4d6240ba0fd..d9568834cbe3 100644 --- a/src/components/MessagesRow.js +++ b/src/components/MessagesRow.js @@ -15,9 +15,7 @@ import Tooltip from './Tooltip'; const propTypes = { /** The messages to display */ - messages: PropTypes.objectOf( - PropTypes.oneOfType([PropTypes.oneOfType([PropTypes.string, PropTypes.object]), PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object]))]), - ), + messages: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object]))])), /** The type of message, 'error' shows a red dot, 'success' shows a green dot */ type: PropTypes.oneOf(['error', 'success']).isRequired, diff --git a/src/languages/en.ts b/src/languages/en.ts index 68af6ec2341d..431727aeec24 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -593,9 +593,6 @@ export default { invalidSplit: 'Split amounts do not equal total amount', other: 'Unexpected error, please try again later', genericCreateFailureMessage: 'Unexpected error requesting money, please try again later', - receiptFailureMessage: "The receipt didn't upload. ", - saveFileMessage: 'Download the file ', - loseFileMessage: 'or dismiss this error and lose it', genericDeleteFailureMessage: 'Unexpected error deleting the money request, please try again later', genericEditFailureMessage: 'Unexpected error editing the money request, please try again later', genericSmartscanFailureMessage: 'Transaction is missing fields', diff --git a/src/languages/es.ts b/src/languages/es.ts index f298839b05b8..77a153e95f73 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -587,9 +587,6 @@ export default { invalidSplit: 'La suma de las partes no equivale al monto total', other: 'Error inesperado, por favor inténtalo más tarde', genericCreateFailureMessage: 'Error inesperado solicitando dinero, Por favor, inténtalo más tarde', - receiptFailureMessage: 'El recibo no se subió. ', - saveFileMessage: 'Guarda el archivo ', - loseFileMessage: 'o descarta este error y piérdelo', genericDeleteFailureMessage: 'Error inesperado eliminando la solicitud de dinero. Por favor, inténtalo más tarde', genericEditFailureMessage: 'Error inesperado al guardar la solicitud de dinero. Por favor, inténtalo más tarde', genericSmartscanFailureMessage: 'La transacción tiene campos vacíos', diff --git a/src/libs/ErrorUtils.ts b/src/libs/ErrorUtils.ts index 46bdd510f5c4..5bc8ea1d3508 100644 --- a/src/libs/ErrorUtils.ts +++ b/src/libs/ErrorUtils.ts @@ -42,14 +42,6 @@ function getMicroSecondOnyxError(error: string): Record { return {[DateUtils.getMicroseconds()]: error}; } -/** - * Method used to get an error object with microsecond as the key and an object as the value. - * @param error - error key or message to be saved - */ -function getMicroSecondOnyxErrorObject(error: Record): Record> { - return {[DateUtils.getMicroseconds()]: error}; -} - type OnyxDataWithErrors = { errors?: Errors; }; @@ -119,4 +111,4 @@ function addErrorMessage(errors: ErrorsList, inpu } } -export {getAuthenticateErrorMessage, getMicroSecondOnyxError, getMicroSecondOnyxErrorObject, getLatestErrorMessage, getLatestErrorField, getEarliestErrorField, addErrorMessage}; +export {getAuthenticateErrorMessage, getMicroSecondOnyxError, getLatestErrorMessage, getLatestErrorField, getEarliestErrorField, addErrorMessage}; diff --git a/src/libs/Localize/index.ts b/src/libs/Localize/index.ts index 488ff0d9b98a..5800d585ec6c 100644 --- a/src/libs/Localize/index.ts +++ b/src/libs/Localize/index.ts @@ -102,6 +102,7 @@ type MaybePhraseKey = string | [string, Record & {isTranslated? * Return translated string for given error. */ function translateIfPhraseKey(message: MaybePhraseKey): string { + debugger; if (!message || (Array.isArray(message) && message.length === 0)) { return ''; } diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 8d44e3898062..939a11dad511 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -141,18 +141,6 @@ function resetMoneyRequestInfo(id = '') { }); } -/** - * Helper function to get the receipt error for money requests, or the generic error if there's no receipt - * - * @param {Object} receipt - * @returns {Object} - */ -function getReceiptError(receipt) { - return _.isEmpty(receipt) - ? ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage') - : ErrorUtils.getMicroSecondOnyxErrorObject({error: CONST.IOU.RECEIPT_ERROR, source: receipt.source, filename: receipt.filename}); -} - function buildOnyxDataForMoneyRequest( chatReport, iouReport, @@ -356,7 +344,7 @@ function buildOnyxDataForMoneyRequest( ...(isNewChatReport ? { [chatCreatedAction.reportActionID]: { - errors: getReceiptError(transaction.receipt), + errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage'), }, [reportPreviewAction.reportActionID]: { errors: ErrorUtils.getMicroSecondOnyxError(null), @@ -365,7 +353,7 @@ function buildOnyxDataForMoneyRequest( : { [reportPreviewAction.reportActionID]: { created: reportPreviewAction.created, - errors: getReceiptError(transaction.receipt), + errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage'), }, }), }, @@ -377,7 +365,7 @@ function buildOnyxDataForMoneyRequest( ...(isNewIOUReport ? { [iouCreatedAction.reportActionID]: { - errors: getReceiptError(transaction.receipt), + errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage'), }, [iouAction.reportActionID]: { errors: ErrorUtils.getMicroSecondOnyxError(null), @@ -385,7 +373,7 @@ function buildOnyxDataForMoneyRequest( } : { [iouAction.reportActionID]: { - errors: getReceiptError(transaction.receipt), + errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage'), }, }), }, @@ -1445,7 +1433,7 @@ function startSplitBill(participants, currentUserLogin, currentUserAccountID, co key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${splitChatReport.reportID}`, value: { [splitIOUReportAction.reportActionID]: { - errors: getReceiptError(receipt), + errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage'), }, }, }); @@ -1468,7 +1456,7 @@ function startSplitBill(participants, currentUserLogin, currentUserAccountID, co errors: ErrorUtils.getMicroSecondOnyxError('report.genericCreateReportFailureMessage'), }, [splitIOUReportAction.reportActionID]: { - errors: getReceiptError(receipt), + errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage'), }, }, }, From 125f162ed0e59eef5bdedf19ba30b26dad568f7e Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Fri, 24 Nov 2023 12:50:30 -0700 Subject: [PATCH 2/2] rm debugger --- src/libs/Localize/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/Localize/index.ts b/src/libs/Localize/index.ts index 5800d585ec6c..488ff0d9b98a 100644 --- a/src/libs/Localize/index.ts +++ b/src/libs/Localize/index.ts @@ -102,7 +102,6 @@ type MaybePhraseKey = string | [string, Record & {isTranslated? * Return translated string for given error. */ function translateIfPhraseKey(message: MaybePhraseKey): string { - debugger; if (!message || (Array.isArray(message) && message.length === 0)) { return ''; }