Skip to content

Commit 8d43bc7

Browse files
committed
Fix the transactions update
1 parent 8a8c088 commit 8d43bc7

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

src/libs/actions/TransactionEdit.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import {format} from 'date-fns';
22
import Onyx from 'react-native-onyx';
3-
import type {Connection, OnyxEntry} from 'react-native-onyx';
3+
import type {Connection, OnyxEntry, OnyxUpdate} from 'react-native-onyx';
44
import {formatCurrentUserToAttendee} from '@libs/IOUUtils';
55
import CONST from '@src/CONST';
66
import ONYXKEYS from '@src/ONYXKEYS';
77
import type {PersonalDetails, Transaction} from '@src/types/onyx';
8-
import type CollectionDataSet from '@src/types/utils/CollectionDataSet';
98
import {generateTransactionID, getDraftTransactions} from './Transaction';
109

1110
let connection: Connection;
@@ -113,8 +112,8 @@ function removeDraftTransactions(shouldExcludeInitialTransaction = false) {
113112
return Onyx.multiSet(draftTransactionsSet);
114113
}
115114

116-
function updateDraftTransactions(transactions: CollectionDataSet<typeof ONYXKEYS.COLLECTION.TRANSACTION_DRAFT>) {
117-
Onyx.mergeCollection(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, transactions);
115+
function updateDraftTransactions(transactionsUpdates: OnyxUpdate[]) {
116+
Onyx.update(transactionsUpdates);
118117
}
119118

120119
function removeTransactionReceipt(transactionID: string | undefined) {

src/pages/iou/request/step/IOURequestStepScan/ReceiptViewModal/index.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, {useCallback, useEffect, useState} from 'react';
22
import {InteractionManager} from 'react-native';
3+
import Onyx from 'react-native-onyx';
34
import AttachmentCarouselView from '@components/Attachments/AttachmentCarousel/AttachmentCarouselView';
45
import useCarouselArrows from '@components/Attachments/AttachmentCarousel/useCarouselArrows';
56
import useAttachmentErrors from '@components/Attachments/AttachmentView/useAttachmentErrors';
@@ -77,13 +78,21 @@ function ReceiptViewModal({route}: ReceiptViewModalProps) {
7778
const secondTransaction = secondTransactionID ? getTransactionOrDraftTransaction(secondTransactionID) : undefined;
7879

7980
if (secondTransaction) {
80-
updateDraftTransactions({
81-
[`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`]: {
82-
...secondTransaction,
83-
transactionID: CONST.IOU.OPTIMISTIC_TRANSACTION_ID,
81+
updateDraftTransactions([
82+
{
83+
onyxMethod: Onyx.METHOD.SET,
84+
key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`,
85+
value: {
86+
...secondTransaction,
87+
transactionID: CONST.IOU.OPTIMISTIC_TRANSACTION_ID,
88+
},
8489
},
85-
[`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${secondTransactionID}`]: null,
86-
});
90+
{
91+
onyxMethod: Onyx.METHOD.MERGE,
92+
key: `${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${secondTransactionID}`,
93+
value: null,
94+
},
95+
]);
8796
}
8897
return;
8998
}

0 commit comments

Comments
 (0)