Skip to content
Closed
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion src/libs/CardUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,12 @@ function checkIfNewFeedConnected(prevFeedsData: CompanyFeeds, currentFeedsData:
const prevFeeds = Object.keys(prevFeedsData);
const currentFeeds = Object.keys(currentFeedsData);

const plaidBankFound = plaidBank && (currentFeeds.includes(`${CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID}.${plaidBank}`) || currentFeeds.find(feed => {
return splitCardFeedWithDomainID(feed as CompanyCardFeedWithDomainID)?.feedName === `${CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID}.${plaidBank}`;
}));

return {
isNewFeedConnected: currentFeeds.length > prevFeeds.length || (plaidBank && currentFeeds.includes(`${CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID}.${plaidBank}`)),
isNewFeedConnected: currentFeeds.length > prevFeeds.length || plaidBankFound,
newFeed: currentFeeds.find((feed) => !prevFeeds.includes(feed)) as CompanyCardFeedWithDomainID | undefined,
};
}
Expand Down
17 changes: 9 additions & 8 deletions src/pages/settings/Wallet/PersonalCards/useGetNewPersonalCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ export default function useGetNewPersonalCard() {
prevCardListRef.current = cardList;
return;
}
const prevCardList = prevCardListRef.current;
const prevIds = new Set(Object.keys(prevCardList));
const currentIds = Object.keys(cardList);
const newCardIds = currentIds.filter((id) => !prevIds.has(id));
if (newCardIds.length > 0) {
for (const id of newCardIds) {
setNewCard(cardList[id]);
}

// Find the first card that is either new or has a fresh import timestamp
const latestChange = Object.values(cardList).find(card => {
const prev = prevCardListRef.current?.[card.cardID];
return !prev || card.lastImportAttempt !== prev.lastImportAttempt;
});

if (latestChange) {
setNewCard(latestChange);
}

prevCardListRef.current = cardList;
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ type Card = OnyxCommon.OnyxValueWithOfflineFeedback<{
/** Last update result */
lastScrapeResult?: number;

/** Last import attempt */
lastImportAttempt?: string;

/** Card related error messages */
errors?: OnyxCommon.Errors;

Expand Down
Loading