Skip to content
Closed
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
14 changes: 10 additions & 4 deletions src/libs/actions/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
import {getPolicyTagsData} from './Policy/Tag';

let recentWaypoints: RecentWaypoint[] = [];
Onyx.connect({

Check warning on line 38 in src/libs/actions/Transaction.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.NVP_RECENT_WAYPOINTS,
callback: (val) => (recentWaypoints = val ?? []),
});

let currentUserEmail = '';

Onyx.connect({

Check warning on line 45 in src/libs/actions/Transaction.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.SESSION,
callback: (value) => {
currentUserEmail = value?.email ?? '';
Expand All @@ -50,7 +50,7 @@
});

const allTransactions: Record<string, Transaction> = {};
Onyx.connect({

Check warning on line 53 in src/libs/actions/Transaction.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,
callback: (transaction, key) => {
if (!key || !transaction) {
Expand All @@ -62,7 +62,7 @@
});

let allTransactionDrafts: OnyxCollection<Transaction> = {};
Onyx.connect({

Check warning on line 65 in src/libs/actions/Transaction.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_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -71,7 +71,7 @@
});

let allReports: OnyxCollection<Report> = {};
Onyx.connect({

Check warning on line 74 in src/libs/actions/Transaction.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.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -83,7 +83,7 @@
});

const allTransactionViolation: OnyxCollection<TransactionViolation[]> = {};
Onyx.connect({

Check warning on line 86 in src/libs/actions/Transaction.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_VIOLATIONS,
callback: (transactionViolation, key) => {
if (!key || !transactionViolation) {
Expand All @@ -95,7 +95,7 @@
});

let allTransactionViolations: TransactionViolations = [];
Onyx.connect({

Check warning on line 98 in src/libs/actions/Transaction.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_VIOLATIONS,
callback: (val) => (allTransactionViolations = val ?? []),
});
Expand Down Expand Up @@ -719,21 +719,19 @@
const oldReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${oldReportID}`];

// 1. Optimistically change the reportID on the passed transactions
const targetReportID = reportID === CONST.REPORT.UNREPORTED_REPORT_ID ? selfDMReportID : reportID;

optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`,
value: {
reportID: targetReportID,
reportID,
},
});

successData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`,
value: {
reportID: targetReportID,
reportID,
},
});

Expand Down Expand Up @@ -798,7 +796,10 @@
}

// 3. Keep track of the new report totals
const isUnreporting = reportID === CONST.REPORT.UNREPORTED_REPORT_ID;

Check failure on line 799 in src/libs/actions/Transaction.ts

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (Unreporting)
const targetReportID = isUnreporting ? selfDMReportID : reportID;

Check failure on line 800 in src/libs/actions/Transaction.ts

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (Unreporting)
const transactionAmount = getAmount(transaction);

if (oldReport) {
updatedReportTotals[oldReportID] = (updatedReportTotals[oldReportID] ? updatedReportTotals[oldReportID] : (oldReport?.total ?? 0)) + transactionAmount;
}
Expand All @@ -811,6 +812,11 @@

const newIOUAction = {
...oldIOUAction,
originalMessage: {
...getOriginalMessage(oldIOUAction),
IOUReportID: reportID,
type: isUnreporting ? CONST.IOU.REPORT_ACTION_TYPE.TRACK : CONST.IOU.REPORT_ACTION_TYPE.CREATE,

Check failure on line 818 in src/libs/actions/Transaction.ts

View workflow job for this annotation

GitHub Actions / 🔍 spellcheck

Unknown word (Unreporting)
},
reportActionID: optimisticMoneyRequestReportActionID,
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
actionName: oldIOUAction?.actionName ?? CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION,
Expand Down Expand Up @@ -907,7 +913,7 @@
let transactionThreadReportID = newIOUAction.childReportID;
let transactionThreadCreatedReportActionID;
if (!transactionThreadReportID) {
const optimisticTransactionThread = buildTransactionThread(newIOUAction, reportID === CONST.REPORT.UNREPORTED_REPORT_ID ? undefined : newReport);

Check failure on line 916 in src/libs/actions/Transaction.ts

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type '{ originalMessage: { IOUReportID: string; type: "create" | "track"; } | { IOUReportID: string; type: "create" | "track"; targetAccountIDs?: number[] | undefined; roomName?: string | undefined; ... 56 more ...; allEnabled?: string | undefined; } | ... 34 more ... | { ...; }; ... 48 more ...; previousMessage?: (Messag...' is not assignable to parameter of type 'OnyxEntry<ReportAction | OptimisticIOUReportAction>'.
const optimisticCreatedActionForTransactionThread = buildOptimisticCreatedReportAction(currentUserEmail);
transactionThreadReportID = optimisticTransactionThread.reportID;
transactionThreadCreatedReportActionID = optimisticCreatedActionForTransactionThread.reportActionID;
Expand Down
Loading