diff --git a/package.json b/package.json index 50c20769cba3..883075e6ba52 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "test:debug": "TZ=utc NODE_OPTIONS='--inspect-brk --experimental-vm-modules' jest --runInBand", "perf-test": "NODE_OPTIONS=--experimental-vm-modules npx reassure", "typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc", - "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=260 --cache --cache-location=node_modules/.cache/eslint", + "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=259 --cache --cache-location=node_modules/.cache/eslint", "lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 ./scripts/lintChanged.sh", "lint-watch": "npx eslint-watch --watch --changed", "shellcheck": "./scripts/shellCheck.sh", diff --git a/src/libs/migrateOnyx.ts b/src/libs/migrateOnyx.ts index f0a9ec9db977..b9b61b669f14 100644 --- a/src/libs/migrateOnyx.ts +++ b/src/libs/migrateOnyx.ts @@ -7,7 +7,6 @@ import PronounsMigration from './migrations/PronounsMigration'; import RemoveEmptyReportActionsDrafts from './migrations/RemoveEmptyReportActionsDrafts'; import RenameCardIsVirtual from './migrations/RenameCardIsVirtual'; import RenameReceiptFilename from './migrations/RenameReceiptFilename'; -import TransactionBackupsToCollection from './migrations/TransactionBackupsToCollection'; export default function () { const startTime = Date.now(); @@ -19,7 +18,6 @@ export default function () { RenameCardIsVirtual, RenameReceiptFilename, KeyReportActionsDraftByReportActionID, - TransactionBackupsToCollection, RemoveEmptyReportActionsDrafts, NVPMigration, PronounsMigration, diff --git a/src/libs/migrations/TransactionBackupsToCollection.ts b/src/libs/migrations/TransactionBackupsToCollection.ts deleted file mode 100644 index 7eff2867c431..000000000000 --- a/src/libs/migrations/TransactionBackupsToCollection.ts +++ /dev/null @@ -1,59 +0,0 @@ -import type {OnyxCollection, OnyxCollectionInputValue, OnyxEntry} from 'react-native-onyx'; -import Onyx from 'react-native-onyx'; -import Log from '@libs/Log'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type {Transaction} from '@src/types/onyx'; - -/** - * This migration moves all the transaction backups stored in the transaction collection, ONYXKEYS.COLLECTION.TRANSACTION, to a reserved collection that only - * stores draft transactions, ONYXKEYS.COLLECTION.TRANSACTION_DRAFT. The purpose of the migration is that there is a possibility that transaction backups are - * not filtered by most functions, e.g, getReportTransactions (src/libs/ReportUtils/index.ts). One problem that arose from storing transaction backups with - * the other transactions is that for every distance expense which have their waypoints updated offline, we expect the preview component to display the - * default image of a pending map. However, due to the presence of the transaction backup, the previous map image will be displayed alongside the pending map. - * The problem was further discussed in this PR. https://github.com/Expensify/App/pull/30232#issuecomment-178110172 - */ -export default function (): Promise { - return new Promise((resolve) => { - const connection = Onyx.connect({ - key: ONYXKEYS.COLLECTION.TRANSACTION, - waitForCollectionCallback: true, - callback: (transactions: OnyxCollection) => { - Onyx.disconnect(connection); - - // Determine whether any transactions were stored - if (!transactions || Object.keys(transactions).length === 0) { - Log.info('[Migrate Onyx] Skipped TransactionBackupsToCollection migration because there are no transactions'); - return resolve(); - } - - const onyxData: OnyxCollectionInputValue = {}; - - // Find all the transaction backups available - Object.keys(transactions).forEach((transactionOnyxKey: string) => { - const transaction: OnyxEntry = transactions[transactionOnyxKey]; - - // Determine whether or not the transaction is a backup - if (transactionOnyxKey.endsWith('-backup') && transaction) { - // Create the transaction backup in the draft transaction collection - onyxData[`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transaction.transactionID}`] = transaction; - - // Delete the transaction backup stored in the transaction collection - onyxData[transactionOnyxKey] = null; - } - }); - - // Determine whether any transaction backups are found - if (Object.keys(onyxData).length === 0) { - Log.info('[Migrate Onyx] Skipped TransactionBackupsToCollection migration because there are no transaction backups'); - return resolve(); - } - - // Move the transaction backups to the draft transaction collection - Onyx.multiSet(onyxData as Partial<{string: [Transaction | null]}>).then(() => { - Log.info('[Migrate Onyx] TransactionBackupsToCollection migration: Successfully moved all the transaction backups to the draft transaction collection'); - resolve(); - }); - }, - }); - }); -}