-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix cycle dependencies in metro console #53852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ab2ef10
3b05f56
1eee276
f28bce0
765e46d
09bffc4
09b1e4c
f490ddc
4d0d477
625283a
43398e7
9795ed6
f1c0869
a03dc83
31847ee
68f4b4e
4711615
642f272
fd30e2a
f688e6c
d76caa2
10d59cd
c64f181
75e9499
e296606
eb23bac
9d79515
e334c63
69dbbab
3b6abbe
cb7bfbc
c748699
b736f16
721bb16
4516381
b772902
60a6a84
bcb22a3
b39b7ae
1ac0dda
2249f9a
969a338
21f10eb
7a8f142
63b3f05
c7f3bdc
6211c2a
b8d4975
b90ad7b
13c3a47
cdeecce
a9ba515
b511fd2
fc00ae9
86d4b70
6b8f188
f838d5a
0eeda29
a214b7c
7b7876e
6f446da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,15 @@ const config = { | |
| // When we run the e2e tests we want files that have the extension e2e.js to be resolved as source files | ||
| sourceExts: [...(isE2ETesting ? e2eSourceExts : []), ...defaultSourceExts, 'jsx'], | ||
| }, | ||
| // We are merging the default config from Expo and React Native and expo one is overriding the React Native one so inlineRequires is set to false so we want to set it to true | ||
| // for fix cycling dependencies and improve performance of app startup | ||
| transformer: { | ||
| getTransformOptions: async () => ({ | ||
| transform: { | ||
| inlineRequires: true, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enabling it caused this top level code to be not immediately evaluated when we named import it. This caused #56158 (comment) and #58322 (comment) |
||
| }, | ||
| }), | ||
| }, | ||
| }; | ||
|
|
||
| module.exports = wrapWithReanimatedMetroConfig(mergeConfig(defaultConfig, expoConfig, config)); | ||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| type ResolveDuplicatesParams = { | ||
| /** The ID of the transaction that we want to keep */ | ||
| transactionID: string; | ||
| transactionID: string | undefined; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure that the api call can be called without valid
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checked it and looks fine when I am passing undefined I am getting same error from API when passing empty string, which say that there are missing information to proceed |
||
|
|
||
| /** The list of other duplicated transactions */ | ||
| transactionIDList: string[]; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,10 +7,10 @@ import type {LastSelectedDistanceRates, OnyxInputOrEntry, Report, Transaction} f | |
| import type {Unit} from '@src/types/onyx/Policy'; | ||
| import type Policy from '@src/types/onyx/Policy'; | ||
| import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
| import * as CurrencyUtils from './CurrencyUtils'; | ||
| import * as PolicyUtils from './PolicyUtils'; | ||
| import * as ReportUtils from './ReportUtils'; | ||
| import * as TransactionUtils from './TransactionUtils'; | ||
| import {getCurrencySymbol} from './CurrencyUtils'; | ||
| import {getDistanceRateCustomUnit, getDistanceRateCustomUnitRate, getPersonalPolicy, getPolicy, getUnitRateValue} from './PolicyUtils'; | ||
| import {isPolicyExpenseChat} from './ReportUtils'; | ||
| import {getCurrency, getRateID, isCustomUnitRateIDForP2P} from './TransactionUtils'; | ||
|
|
||
| type MileageRate = { | ||
| customUnitRateID?: string; | ||
|
|
@@ -48,7 +48,7 @@ function getMileageRates(policy: OnyxInputOrEntry<Policy>, includeDisabledRates | |
| return mileageRates; | ||
| } | ||
|
|
||
| const distanceUnit = PolicyUtils.getDistanceRateCustomUnit(policy); | ||
| const distanceUnit = getDistanceRateCustomUnit(policy); | ||
| if (!distanceUnit?.rates) { | ||
| return mileageRates; | ||
| } | ||
|
|
@@ -90,7 +90,7 @@ function getDefaultMileageRate(policy: OnyxInputOrEntry<Policy>): MileageRate | | |
| return undefined; | ||
| } | ||
|
|
||
| const distanceUnit = PolicyUtils.getDistanceRateCustomUnit(policy); | ||
| const distanceUnit = getDistanceRateCustomUnit(policy); | ||
| if (!distanceUnit?.rates || !distanceUnit.attributes) { | ||
| return; | ||
| } | ||
|
|
@@ -162,9 +162,9 @@ function getRateForDisplay( | |
| } | ||
|
|
||
| const singularDistanceUnit = unit === CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES ? translate('common.mile') : translate('common.kilometer'); | ||
| const formattedRate = PolicyUtils.getUnitRateValue(toLocaleDigit, {rate}, useShortFormUnit); | ||
| const formattedRate = getUnitRateValue(toLocaleDigit, {rate}, useShortFormUnit); | ||
| // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
| const currencySymbol = CurrencyUtils.getCurrencySymbol(currency) || `${currency} `; | ||
| const currencySymbol = getCurrencySymbol(currency) || `${currency} `; | ||
|
|
||
| return `${currencySymbol}${formattedRate} / ${useShortFormUnit ? unit : singularDistanceUnit}`; | ||
| } | ||
|
|
@@ -250,7 +250,7 @@ function getRateForP2P(currency: string, transaction: OnyxEntry<Transaction>): M | |
| ensureRateDefined(mileageRate.rate); | ||
|
|
||
| // Ensure the rate is updated when the currency changes, otherwise use the stored rate | ||
| const rate = TransactionUtils.getCurrency(transaction) === currency ? transaction?.comment?.customUnit?.defaultP2PRate ?? mileageRate.rate : mileageRate.rate; | ||
| const rate = getCurrency(transaction) === currency ? transaction?.comment?.customUnit?.defaultP2PRate ?? mileageRate.rate : mileageRate.rate; | ||
| return { | ||
| ...mileageRate, | ||
| currency: currencyWithExistingRate, | ||
|
|
@@ -297,13 +297,13 @@ function getCustomUnitRateID(reportID?: string) { | |
| } | ||
| const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; | ||
| const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`]; | ||
| const policy = PolicyUtils.getPolicy(report?.policyID ?? parentReport?.policyID); | ||
| const policy = getPolicy(report?.policyID ?? parentReport?.policyID); | ||
|
|
||
| if (isEmptyObject(policy)) { | ||
| return customUnitRateID; | ||
| } | ||
|
|
||
| if (ReportUtils.isPolicyExpenseChat(report) || ReportUtils.isPolicyExpenseChat(parentReport)) { | ||
| if (isPolicyExpenseChat(report) || isPolicyExpenseChat(parentReport)) { | ||
| const distanceUnit = Object.values(policy.customUnits ?? {}).find((unit) => unit.name === CONST.CUSTOM_UNITS.NAME_DISTANCE); | ||
| const lastSelectedDistanceRateID = lastSelectedDistanceRates?.[policy.id]; | ||
| const lastSelectedDistanceRate = lastSelectedDistanceRateID ? distanceUnit?.rates[lastSelectedDistanceRateID] : undefined; | ||
|
|
@@ -325,15 +325,15 @@ function getCustomUnitRateID(reportID?: string) { | |
| * Get taxable amount from a specific distance rate, taking into consideration the tax claimable amount configured for the distance rate | ||
| */ | ||
| function getTaxableAmount(policy: OnyxEntry<Policy>, customUnitRateID: string, distance: number) { | ||
| const distanceUnit = PolicyUtils.getDistanceRateCustomUnit(policy); | ||
| const customUnitRate = PolicyUtils.getDistanceRateCustomUnitRate(policy, customUnitRateID); | ||
| if (!distanceUnit || !distanceUnit?.customUnitID || !customUnitRate) { | ||
| const distanceUnit = getDistanceRateCustomUnit(policy); | ||
| const customUnitRate = getDistanceRateCustomUnitRate(policy, customUnitRateID); | ||
| if (!distanceUnit?.customUnitID || !customUnitRate) { | ||
| return 0; | ||
| } | ||
| const unit = distanceUnit?.attributes?.unit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES; | ||
| const rate = customUnitRate?.rate ?? 0; | ||
| const rate = customUnitRate?.rate ?? CONST.DEFAULT_NUMBER_ID; | ||
| const amount = getDistanceRequestAmount(distance, unit, rate); | ||
| const taxClaimablePercentage = customUnitRate.attributes?.taxClaimablePercentage ?? 0; | ||
| const taxClaimablePercentage = customUnitRate.attributes?.taxClaimablePercentage ?? CONST.DEFAULT_NUMBER_ID; | ||
| return amount * taxClaimablePercentage; | ||
| } | ||
|
|
||
|
|
@@ -360,10 +360,11 @@ function getRate({ | |
| if (isEmptyObject(mileageRates) && policyDraft) { | ||
| mileageRates = getMileageRates(policyDraft, true, transaction?.comment?.customUnit?.customUnitRateID); | ||
| } | ||
| const policyCurrency = policy?.outputCurrency ?? PolicyUtils.getPersonalPolicy()?.outputCurrency ?? CONST.CURRENCY.USD; | ||
| const policyCurrency = policy?.outputCurrency ?? getPersonalPolicy()?.outputCurrency ?? CONST.CURRENCY.USD; | ||
| const defaultMileageRate = getDefaultMileageRate(policy); | ||
| const customUnitRateID = TransactionUtils.getRateID(transaction) ?? ''; | ||
| const mileageRate = TransactionUtils.isCustomUnitRateIDForP2P(transaction) ? getRateForP2P(policyCurrency, transaction) : mileageRates?.[customUnitRateID] ?? defaultMileageRate; | ||
| const customUnitRateID = getRateID(transaction); | ||
| const customMileageRate = customUnitRateID ? mileageRates?.[customUnitRateID] : defaultMileageRate; | ||
|
Comment on lines
+365
to
+366
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This leads to set undefined for the mileageRate and caused issue #55245 |
||
| const mileageRate = isCustomUnitRateIDForP2P(transaction) ? getRateForP2P(policyCurrency, transaction) : customMileageRate; | ||
| const unit = getDistanceUnit(useTransactionDistanceUnit ? transaction : undefined, mileageRate); | ||
| return { | ||
| ...mileageRate, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.