diff --git a/package.json b/package.json index d48101f0993d..caea4da72ec9 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=249 --cache --cache-location=node_modules/.cache/eslint", + "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=246 --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/ONYXKEYS.ts b/src/ONYXKEYS.ts index 68b53dc54083..3637ad7772e5 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -589,7 +589,6 @@ const ONYXKEYS = { // should not be included as part of the policy object. The policy // object should mirror the data as it's stored in the database. POLICY_HAS_CONNECTIONS_DATA_BEEN_FETCHED: 'policyHasConnectionsDataBeenFetched_', - OLD_POLICY_RECENTLY_USED_TAGS: 'policyRecentlyUsedTags_', POLICY_CONNECTION_SYNC_PROGRESS: 'policyConnectionSyncProgress_', WORKSPACE_INVITE_MEMBERS_DRAFT: 'workspaceInviteMembersDraft_', WORKSPACE_INVITE_MESSAGE_DRAFT: 'workspaceInviteMessageDraft_', @@ -1024,7 +1023,6 @@ type OnyxCollectionValuesMapping = { [ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT]: OnyxTypes.Transaction; [ONYXKEYS.COLLECTION.MERGE_TRANSACTION]: OnyxTypes.MergeTransaction; [ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS]: OnyxTypes.RecentlyUsedTags; - [ONYXKEYS.COLLECTION.OLD_POLICY_RECENTLY_USED_TAGS]: OnyxTypes.RecentlyUsedTags; [ONYXKEYS.COLLECTION.SELECTED_TAB]: OnyxTypes.SelectedTabRequest; [ONYXKEYS.COLLECTION.PRIVATE_NOTES_DRAFT]: string; [ONYXKEYS.COLLECTION.NVP_EXPENSIFY_REPORT_PDF_FILENAME]: string; diff --git a/src/libs/migrateOnyx.ts b/src/libs/migrateOnyx.ts index 2719efb797b6..59b62b563ebd 100644 --- a/src/libs/migrateOnyx.ts +++ b/src/libs/migrateOnyx.ts @@ -2,7 +2,6 @@ import Log from './Log'; import KeyReportActionsDraftByReportActionID from './migrations/KeyReportActionsDraftByReportActionID'; import MoveDraftsToNVP from './migrations/MoveDraftsToNVP'; import MoveIsOptimisticReportToMetadata from './migrations/MoveIsOptimisticReportToMetadata'; -import NVPMigration from './migrations/NVPMigration'; import PendingMembersToMetadata from './migrations/PendingMembersToMetadata'; import PronounsMigration from './migrations/PronounsMigration'; import RenameCardIsVirtual from './migrations/RenameCardIsVirtual'; @@ -18,7 +17,6 @@ export default function () { RenameCardIsVirtual, RenameReceiptFilename, KeyReportActionsDraftByReportActionID, - NVPMigration, PronounsMigration, MoveIsOptimisticReportToMetadata, PendingMembersToMetadata, diff --git a/src/libs/migrations/NVPMigration.ts b/src/libs/migrations/NVPMigration.ts deleted file mode 100644 index 6a4f61f30407..000000000000 --- a/src/libs/migrations/NVPMigration.ts +++ /dev/null @@ -1,79 +0,0 @@ -import after from 'lodash/after'; -import Onyx from 'react-native-onyx'; -import type {KeyValueMapping, OnyxEntry} from 'react-native-onyx'; -import type {Account} from 'src/types/onyx'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type {OnyxKey} from '@src/ONYXKEYS'; - -// These are the oldKeyName: newKeyName of the NVPs we can migrate without any processing -const migrations = { - // eslint-disable-next-line @typescript-eslint/naming-convention - nvp_lastPaymentMethod: ONYXKEYS.NVP_LAST_PAYMENT_METHOD, - preferredLocale: ONYXKEYS.NVP_PREFERRED_LOCALE, - preferredEmojiSkinTone: ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE, - frequentlyUsedEmojis: ONYXKEYS.FREQUENTLY_USED_EMOJIS, - private_blockedFromConcierge: ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE, - private_pushNotificationID: ONYXKEYS.NVP_PRIVATE_PUSH_NOTIFICATION_ID, - tryFocusMode: ONYXKEYS.NVP_TRY_FOCUS_MODE, - introSelected: ONYXKEYS.NVP_INTRO_SELECTED, - preferredTheme: ONYXKEYS.PREFERRED_THEME, -}; - -// This migration changes the keys of all the NVP related keys so that they are standardized -export default function () { - return new Promise((resolve) => { - // Resolve the migration when all the keys have been migrated. The number of keys is the size of the `migrations` object in addition to the ACCOUNT and OLD_POLICY_RECENTLY_USED_TAGS keys (which is why there is a +2). - const resolveWhenDone = after(Object.entries(migrations).length + 2, () => resolve()); - - for (const [oldKey, newKey] of Object.entries(migrations)) { - const connection = Onyx.connect({ - key: oldKey as OnyxKey, - callback: (value) => { - Onyx.disconnect(connection); - if (value === undefined) { - resolveWhenDone(); - return; - } - Onyx.multiSet({ - [newKey]: value, - [oldKey]: null, - } as KeyValueMapping).then(resolveWhenDone); - }, - }); - } - const accountConnection = Onyx.connect({ - key: ONYXKEYS.ACCOUNT, - callback: (value: OnyxEntry) => { - Onyx.disconnect(accountConnection); - if (!value?.activePolicyID) { - resolveWhenDone(); - return; - } - const activePolicyID = value.activePolicyID; - const newValue = {...value}; - delete newValue.activePolicyID; - Onyx.multiSet({ - [ONYXKEYS.NVP_ACTIVE_POLICY_ID]: activePolicyID, - [ONYXKEYS.ACCOUNT]: newValue, - }).then(resolveWhenDone); - }, - }); - const recentlyUsedTagsConnection = Onyx.connect({ - key: ONYXKEYS.COLLECTION.OLD_POLICY_RECENTLY_USED_TAGS, - waitForCollectionCallback: true, - callback: (value) => { - Onyx.disconnect(recentlyUsedTagsConnection); - if (!value) { - resolveWhenDone(); - return; - } - const newValue = {} as Record; - for (const key of Object.keys(value)) { - newValue[`nvp_${key}`] = value[key]; - newValue[key] = null; - } - Onyx.multiSet(newValue as KeyValueMapping).then(resolveWhenDone); - }, - }); - }); -}