-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix optimistic data for distance request #32943
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,20 @@ Onyx.connect({ | |
}, | ||
}); | ||
|
||
let allTransactionDrafts; | ||
Onyx.connect({ | ||
key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, | ||
waitForCollectionCallback: true, | ||
callback: (val) => { | ||
if (!val) { | ||
allTransactionDrafts = {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usually, the variable is initialized to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
return; | ||
} | ||
|
||
allTransactionDrafts = val; | ||
}, | ||
}); | ||
|
||
let allTransactionViolations; | ||
Onyx.connect({ | ||
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, | ||
|
@@ -661,11 +675,12 @@ function getMoneyRequestInformation( | |
// data. This is a big can of worms to change it to `Onyx.merge()` as explored in https://expensify.slack.com/archives/C05DWUDHVK7/p1692139468252109. | ||
// I want to clean this up at some point, but it's possible this will live in the code for a while so I've created https://github.com/Expensify/App/issues/25417 | ||
// to remind me to do this. | ||
const existingTransaction = existingTransactionID && TransactionUtils.getTransaction(existingTransactionID); | ||
if (existingTransaction) { | ||
const existingTransaction = allTransactionDrafts[`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`]; | ||
if (existingTransaction && existingTransaction.iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE) { | ||
optimisticTransaction = { | ||
...optimisticTransaction, | ||
...existingTransaction, | ||
transactionID: optimisticTransaction.transactionID, | ||
}; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tgolen So we will initialize it here, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luacmartins Updated.