-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Cache getBankName #84055
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
Cache getBankName #84055
Changes from all commits
ff0264c
10a8506
ab2e741
88856e4
0a1d13d
6b47c87
4160a9d
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 |
|---|---|---|
|
|
@@ -2474,6 +2474,7 @@ function getCardSections( | |
| cardList?: OnyxTypes.CardList, | ||
| ): [TransactionCardGroupListItemType[], number] { | ||
| const cardSections: Record<string, TransactionCardGroupListItemType> = {}; | ||
| const cardDescriptionByCardID = new Map<number, string>(); | ||
|
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. I think we can also move it to the top-level scope of the file.
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. I think we can keep it inside the function to avoid issues where the locale is changed and the description doesn't change
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. Ah, I agree. I can see the |
||
|
|
||
| for (const key in data) { | ||
| if (isGroupEntry(key)) { | ||
|
|
@@ -2486,16 +2487,13 @@ function getCardSections( | |
| } | ||
|
|
||
| const card = cardList?.[cardGroup.cardID]; | ||
|
|
||
| cardSections[key] = { | ||
| groupedBy: CONST.SEARCH.GROUP_BY.CARD, | ||
| transactions: [], | ||
| transactionsQueryJSON, | ||
| ...personalDetails, | ||
| ...cardGroup, | ||
| formattedCardName: | ||
| customCardNames?.[cardGroup.cardID] ?? | ||
| getCardDescription( | ||
| let formattedCardName = customCardNames?.[cardGroup.cardID]; | ||
| if (formattedCardName === undefined) { | ||
| const cached = cardDescriptionByCardID.get(cardGroup.cardID); | ||
| if (cached !== undefined) { | ||
| formattedCardName = cached; | ||
| } else { | ||
| formattedCardName = getCardDescription( | ||
| { | ||
| cardID: cardGroup.cardID, | ||
| bank: cardGroup.bank, | ||
|
|
@@ -2504,7 +2502,18 @@ function getCardSections( | |
| lastFourPAN: cardGroup.lastFourPAN, | ||
| } as OnyxTypes.Card, | ||
| translate, | ||
| ), | ||
| ); | ||
| cardDescriptionByCardID.set(cardGroup.cardID, formattedCardName); | ||
| } | ||
| } | ||
|
|
||
| cardSections[key] = { | ||
| groupedBy: CONST.SEARCH.GROUP_BY.CARD, | ||
| transactions: [], | ||
| transactionsQueryJSON, | ||
| ...personalDetails, | ||
| ...cardGroup, | ||
| formattedCardName, | ||
| formattedFeedName: getFeedNameForDisplay(translate, cardGroup.bank as OnyxTypes.CompanyCardFeed, cardFeeds), | ||
| }; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.