Skip to content

Commit

Permalink
Merge pull request #40665 from Expensify/mountiny-cherry-pick-staging…
Browse files Browse the repository at this point in the history
…-40655-1

🍒 Cherry pick PR #40655 to staging 🍒
  • Loading branch information
srikarparsi authored Apr 21, 2024
2 parents e65cc28 + acafa95 commit f8d48b8
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 17 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001046315
versionName "1.4.63-15"
versionCode 1001046316
versionName "1.4.63-16"
// Supported language variants must be declared here to avoid from being removed during the compilation.
// This also helps us to not include unnecessary language variants in the APK.
resConfigs "en", "es"
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.4.63.15</string>
<string>1.4.63.16</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.4.63.15</string>
<string>1.4.63.16</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion ios/NotificationServiceExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<key>CFBundleShortVersionString</key>
<string>1.4.63</string>
<key>CFBundleVersion</key>
<string>1.4.63.15</string>
<string>1.4.63.16</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.4.63-15",
"version": "1.4.63-16",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
19 changes: 18 additions & 1 deletion src/libs/actions/TransactionEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,21 @@ function restoreOriginalTransactionFromBackup(transactionID: string, isDraft: bo
});
}

export {createBackupTransaction, removeBackupTransaction, restoreOriginalTransactionFromBackup};
function createDraftTransaction(transaction: OnyxEntry<Transaction>) {
if (!transaction) {
return;
}

const newTransaction = {
...transaction,
};

// Use set so that it will always fully overwrite any backup transaction that could have existed before
Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transaction.transactionID}`, newTransaction);
}

function removeDraftTransaction(transactionID: string) {
Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, null);
}

export {createBackupTransaction, removeBackupTransaction, restoreOriginalTransactionFromBackup, createDraftTransaction, removeDraftTransaction};
16 changes: 8 additions & 8 deletions src/pages/iou/request/step/IOURequestStepAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type IOURequestStepAmountOnyxProps = {
/** The draft transaction that holds data to be persisted on the current transaction */
splitDraftTransaction: OnyxEntry<Transaction>;

/** The backup transaction object being modified in Onyx */
backupTransaction: OnyxEntry<Transaction>;
/** The draft transaction object being modified in Onyx */
draftTransaction: OnyxEntry<Transaction>;
};

type IOURequestStepAmountProps = IOURequestStepAmountOnyxProps &
Expand All @@ -48,7 +48,7 @@ function IOURequestStepAmount({
},
transaction,
splitDraftTransaction,
backupTransaction,
draftTransaction,
}: IOURequestStepAmountProps) {
const {translate} = useLocalize();
const textInput = useRef<BaseTextInputRef | null>(null);
Expand All @@ -59,7 +59,7 @@ function IOURequestStepAmount({
const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT;
const isEditingSplitBill = isEditing && isSplitBill;
const {amount: transactionAmount} = ReportUtils.getTransactionDetails(isEditingSplitBill && !isEmptyObject(splitDraftTransaction) ? splitDraftTransaction : transaction) ?? {amount: 0};
const {currency: originalCurrency} = ReportUtils.getTransactionDetails(isEditing ? backupTransaction : transaction) ?? {currency: CONST.CURRENCY.USD};
const {currency: originalCurrency} = ReportUtils.getTransactionDetails(isEditing ? draftTransaction : transaction) ?? {currency: CONST.CURRENCY.USD};
const currency = CurrencyUtils.isValidCurrencyCode(selectedCurrency) ? selectedCurrency : originalCurrency;

useFocusEffect(
Expand All @@ -81,13 +81,13 @@ function IOURequestStepAmount({
// A temporary solution to not prevent users from editing the currency
// We create a backup transaction and use it to save the currency and remove this transaction backup if we don't save the amount
// It should be removed after this issue https://github.com/Expensify/App/issues/34607 is fixed
TransactionEdit.createBackupTransaction(isEditingSplitBill && !isEmptyObject(splitDraftTransaction) ? splitDraftTransaction : transaction);
TransactionEdit.createDraftTransaction(isEditingSplitBill && !isEmptyObject(splitDraftTransaction) ? splitDraftTransaction : transaction);

return () => {
if (isSaveButtonPressed.current) {
return;
}
TransactionEdit.removeBackupTransaction(transaction?.transactionID ?? '');
TransactionEdit.removeDraftTransaction(transaction?.transactionID ?? '');
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand Down Expand Up @@ -184,10 +184,10 @@ export default withWritableReportOrNotFound(
return `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`;
},
},
backupTransaction: {
draftTransaction: {
key: ({route}) => {
const transactionID = route.params.transactionID ?? 0;
return `${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`;
return `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`;
},
},
})(IOURequestStepAmount),
Expand Down

0 comments on commit f8d48b8

Please sign in to comment.