Skip to content

Commit 93d9c21

Browse files
committed
Resolve post-merge typecheck errors
Main renamed PLAID_LINK_TOKEN to RAM_ONLY_PLAID_LINK_TOKEN and removed updatePersonalCardConnection as an unused export; restore the action and update the consumers to the renamed key.
1 parent 98a4f08 commit 93d9c21

3 files changed

Lines changed: 69 additions & 4 deletions

File tree

src/libs/actions/PersonalCards.ts

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import type {NullishDeep} from 'react-native-onyx';
1+
import type {NullishDeep, OnyxUpdate} from 'react-native-onyx';
22
import Onyx from 'react-native-onyx';
3+
import {write} from '@libs/API';
4+
import {WRITE_COMMANDS} from '@libs/API/types';
5+
import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils';
6+
import CONST from '@src/CONST';
37
import ONYXKEYS from '@src/ONYXKEYS';
48
import type {AddNewPersonalCard, AddNewPersonalCardFeedData, AddNewPersonalCardFeedStep} from '@src/types/onyx/PersonalCard';
59

@@ -29,4 +33,65 @@ function clearAddNewPersonalCardErrors() {
2933
Onyx.merge(ONYXKEYS.ADD_NEW_PERSONAL_CARD, {errors: null});
3034
}
3135

32-
export {clearAddNewPersonalCardErrors, clearAddNewPersonalCardFlow, setAddNewPersonalCardStepAndData};
36+
function updatePersonalCardConnection(cardID: string, lastScrapeResult?: number) {
37+
const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST | typeof ONYXKEYS.CARD_LIST>> = [
38+
{
39+
onyxMethod: Onyx.METHOD.MERGE,
40+
key: ONYXKEYS.CARD_LIST,
41+
value: {
42+
[cardID]: {
43+
lastScrapeResult: CONST.JSON_CODE.SUCCESS,
44+
isLoadingLastUpdated: true,
45+
pendingFields: {
46+
lastScrape: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
47+
},
48+
errorFields: {
49+
lastScrape: null,
50+
},
51+
},
52+
},
53+
},
54+
];
55+
56+
const finallyData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST | typeof ONYXKEYS.CARD_LIST>> = [
57+
{
58+
onyxMethod: Onyx.METHOD.MERGE,
59+
key: ONYXKEYS.CARD_LIST,
60+
value: {
61+
[cardID]: {
62+
isLoadingLastUpdated: false,
63+
pendingFields: {
64+
lastScrape: null,
65+
},
66+
},
67+
},
68+
},
69+
];
70+
71+
const failureData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST | typeof ONYXKEYS.CARD_LIST>> = [
72+
{
73+
onyxMethod: Onyx.METHOD.MERGE,
74+
key: ONYXKEYS.CARD_LIST,
75+
value: {
76+
[cardID]: {
77+
lastScrapeResult,
78+
isLoadingLastUpdated: false,
79+
pendingFields: {
80+
lastScrape: null,
81+
},
82+
errorFields: {
83+
lastScrape: getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'),
84+
},
85+
},
86+
},
87+
},
88+
];
89+
90+
const parameters = {
91+
cardID: Number(cardID),
92+
};
93+
94+
write(WRITE_COMMANDS.SYNC_CARD, parameters, {optimisticData, finallyData, failureData});
95+
}
96+
97+
export {clearAddNewPersonalCardErrors, clearAddNewPersonalCardFlow, setAddNewPersonalCardStepAndData, updatePersonalCardConnection};

src/pages/settings/Wallet/PersonalCards/FixPersonalCardConnectionPage/index.native.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function FixPersonalCardConnectionPage({route}: FixPersonalCardConnectionPagePro
4545
const hasRequestedPlaidToken = useRef(false);
4646

4747
const [session] = useOnyx(ONYXKEYS.SESSION);
48-
const [plaidLinkToken] = useOnyx(ONYXKEYS.PLAID_LINK_TOKEN);
48+
const [plaidLinkToken] = useOnyx(ONYXKEYS.RAM_ONLY_PLAID_LINK_TOKEN);
4949
const [plaidData] = useOnyx(ONYXKEYS.PLAID_DATA);
5050
const [isPlaidDisabled] = useOnyx(ONYXKEYS.IS_PLAID_DISABLED);
5151
const authToken = session?.authToken ?? null;

src/pages/settings/Wallet/PersonalCards/FixPersonalCardConnectionPage/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function FixPersonalCardConnectionPage({route}: FixPersonalCardConnectionPagePro
3939
const illustrations = useMemoizedLazyIllustrations(['PendingBank']);
4040
const {card, bankDisplayName, url, isOffline, isPlaid, country} = useFixPersonalCardConnection(cardID);
4141

42-
const [plaidLinkToken] = useOnyx(ONYXKEYS.PLAID_LINK_TOKEN);
42+
const [plaidLinkToken] = useOnyx(ONYXKEYS.RAM_ONLY_PLAID_LINK_TOKEN);
4343
const [plaidData] = useOnyx(ONYXKEYS.PLAID_DATA);
4444
const [isPlaidDisabled] = useOnyx(ONYXKEYS.IS_PLAID_DISABLED);
4545

0 commit comments

Comments
 (0)