Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions src/libs/actions/TransactionEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
const newTransaction = {
...transaction,
};
const conn = Onyx.connect({

Check warning on line 27 in src/libs/actions/TransactionEdit.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: `${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transaction.transactionID}`,
callback: (transactionBackup) => {
Onyx.disconnect(conn);
Expand Down Expand Up @@ -56,7 +56,7 @@
return;
}

connection = Onyx.connect({

Check warning on line 59 in src/libs/actions/TransactionEdit.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: `${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`,
callback: (backupTransaction) => {
Onyx.disconnect(connection);
Expand Down Expand Up @@ -99,38 +99,6 @@

function removeDraftTransactions(shouldExcludeInitialTransaction = false, allTransactionDrafts?: OnyxCollection<Transaction>) {
const draftTransactions = getDraftTransactions(allTransactionDrafts);

if (!draftTransactions || draftTransactions.length === 0) {
return new Promise<void>((resolve) => {
// We do not depend on updates on the UI to remove draft transactions
// so we are safe to use `connectWithoutView` here.
const conn = Onyx.connectWithoutView({
key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (draftTransactionCollection) => {
Onyx.disconnect(conn);

if (!draftTransactionCollection) {
resolve();
return;
}

const draftTransactionsSet = Object.keys(draftTransactionCollection).reduce(
(acc, key) => {
if (shouldExcludeInitialTransaction && key.replace(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, '') === CONST.IOU.OPTIMISTIC_TRANSACTION_ID) {
return acc;
}
acc[key] = null;
return acc;
},
{} as Record<string, null>,
);
Onyx.multiSet(draftTransactionsSet).then(() => resolve());
},
});
});
}

const draftTransactionsSet = draftTransactions.reduce(
(acc, item) => {
if (shouldExcludeInitialTransaction && item.transactionID === CONST.IOU.OPTIMISTIC_TRANSACTION_ID) {
Expand Down
Loading