Skip to content

Commit a6deabe

Browse files
authored
chore: develop to preview (#4470)
2 parents 44c5af5 + 05347e7 commit a6deabe

File tree

4 files changed

+52
-72
lines changed

4 files changed

+52
-72
lines changed

mobile/src/features/Links/components/ActionHandler.tsx

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,7 @@ export const ActionHandler = () => {
139139
// Update observables when React state changes
140140
React.useEffect(() => {
141141
if (pendingAction) {
142-
const newActionId = createActionId(pendingAction)
143-
// If this actionId was processed before, check if it's a new instance
144-
if (newActionId && processedActionsRef.current.has(newActionId)) {
145-
const previousAction = processedActionsRef.current.get(newActionId)
146-
// If the action object reference is different, it's a new trigger
147-
if (previousAction !== pendingAction) {
148-
// Same actionId but new instance - clear to allow reprocessing
149-
processedActionsRef.current.delete(newActionId)
150-
isProcessingRef.current = false
151-
}
152-
}
153-
currentActionIdRef.current = newActionId
142+
currentActionIdRef.current = createActionId(pendingAction)
154143
} else {
155144
currentActionIdRef.current = null
156145
}
@@ -168,10 +157,8 @@ export const ActionHandler = () => {
168157
}, [wallet])
169158

170159
// Track processing state
171-
// Map actionId -> pendingAction object reference to detect new triggers
172-
const processedActionsRef = React.useRef<Map<string, PendingAction | null>>(
173-
new Map(),
174-
)
160+
// Set of actionIds that have been processed
161+
const processedActionsRef = React.useRef<Set<string>>(new Set())
175162
const isProcessingRef = React.useRef(false)
176163
const hasShownModalRef = React.useRef(false)
177164
const prevWalletRef = React.useRef<typeof wallet>(wallet)
@@ -319,19 +306,8 @@ export const ActionHandler = () => {
319306
return
320307
}
321308

322-
// Check if we've already processed this exact action instance
323-
if (actionId && processedActionsRef.current.has(actionId)) {
324-
const processedAction = processedActionsRef.current.get(actionId)
325-
// If it's the same action object reference, skip (already processing)
326-
if (processedAction === action) {
327-
return
328-
}
329-
// Different action object with same actionId - new trigger, allow it
330-
processedActionsRef.current.delete(actionId)
331-
isProcessingRef.current = false
332-
}
333-
334-
if (!actionId) {
309+
// Check if we've already processed this action
310+
if (!actionId || processedActionsRef.current.has(actionId)) {
335311
return
336312
}
337313

@@ -340,8 +316,7 @@ export const ActionHandler = () => {
340316
}
341317

342318
isProcessingRef.current = true
343-
// Store action object reference, not just actionId
344-
processedActionsRef.current.set(actionId, action)
319+
processedActionsRef.current.add(actionId)
345320

346321
InteractionManager.runAfterInteractions(() => {
347322
try {

mobile/src/features/Links/components/ClaimActionHandler.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import {logger} from '~/kernel/logger/logger'
1818
export const ClaimActionHandler = () => {
1919
const {pendingAction} = useLinks()
2020
const {reset: resetClaimState, scanActionClaimChanged, address} = useClaim()
21-
const processedActionRef = React.useRef<Links.CardanoActionClaim | null>(null)
21+
// Track processed claim URLs to prevent re-processing
22+
const processedClaimUrlsRef = React.useRef<Set<string>>(new Set())
2223

2324
// Handle claim action from pendingAction context
2425
// Use useFocusEffect to ensure we process when screen is focused
@@ -48,12 +49,9 @@ export const ClaimActionHandler = () => {
4849
) {
4950
const cardanoAction = pendingAction.action as Links.CardanoActionClaim
5051

51-
// Check if we've already processed this action
52-
if (
53-
processedActionRef.current &&
54-
processedActionRef.current.url === cardanoAction.url &&
55-
processedActionRef.current.code === cardanoAction.code
56-
) {
52+
// Check if we've already processed this claim URL
53+
const claimKey = `${cardanoAction.url}:${cardanoAction.code}`
54+
if (processedClaimUrlsRef.current.has(claimKey)) {
5755
logger.info(
5856
'ClaimActionHandler: action already processed, skipping',
5957
{
@@ -75,7 +73,7 @@ export const ClaimActionHandler = () => {
7573
scanActionClaimChanged(cardanoAction)
7674

7775
// Mark as processed to prevent re-processing if screen refocuses
78-
processedActionRef.current = cardanoAction
76+
processedClaimUrlsRef.current.add(claimKey)
7977
} else {
8078
logger.info('ClaimActionHandler: conditions not met', {
8179
hasPendingAction: !!pendingAction,

mobile/src/features/Links/hooks/useDeepLinkWatcher.tsx

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export const useDeepLinkWatcher = () => {
1212
const {isLoggedIn} = useAuth()
1313
const {pendingAction, setPendingAction} = useLinks()
1414

15+
// Track URLs that have already been processed to prevent re-processing
16+
// when processLink callback reference changes
17+
const processedUrlsRef = React.useRef<Set<string>>(new Set())
18+
1519
const processLink = React.useCallback(
1620
(url: string) => {
1721
// Try Yoroi links first (yoroi://)
@@ -70,7 +74,8 @@ export const useDeepLinkWatcher = () => {
7074
React.useEffect(() => {
7175
const getInitialURL = async () => {
7276
const url = await Linking.getInitialURL()
73-
if (url !== null) {
77+
if (url !== null && !processedUrlsRef.current.has(url)) {
78+
processedUrlsRef.current.add(url)
7479
processLink(url)
7580
}
7681
}
@@ -92,40 +97,42 @@ export const useDeepLinkWatcher = () => {
9297
const checkInitialUrlAfterLogin = async () => {
9398
const url = await Linking.getInitialURL()
9499

95-
if (url !== null) {
96-
// Try both Yoroi and Cardano links
97-
const parsedYoroiAction = linksYoroiParser(url)
98-
if (parsedYoroiAction != null) {
99-
if (
100-
parsedYoroiAction.params?.isSandbox === true &&
101-
__DEV__ === false
102-
) {
103-
return
104-
}
105-
const pendingAction: PendingAction = {
106-
source: 'yoroi',
107-
action: {info: parsedYoroiAction, isTrusted: false},
108-
}
109-
setPendingAction(pendingAction)
100+
// Skip if URL was already processed
101+
if (url === null || processedUrlsRef.current.has(url)) {
102+
return
103+
}
104+
105+
// Try both Yoroi and Cardano links
106+
const parsedYoroiAction = linksYoroiParser(url)
107+
if (parsedYoroiAction != null) {
108+
if (parsedYoroiAction.params?.isSandbox === true && __DEV__ === false) {
110109
return
111110
}
111+
processedUrlsRef.current.add(url)
112+
const pendingAction: PendingAction = {
113+
source: 'yoroi',
114+
action: {info: parsedYoroiAction, isTrusted: false},
115+
}
116+
setPendingAction(pendingAction)
117+
return
118+
}
112119

113-
if (isWebCardanoLink(url)) {
114-
try {
115-
const cardanoAction = parseCardanoLink(url)
116-
const pendingAction: PendingAction = {
117-
source: 'cardano',
118-
action: cardanoAction,
119-
}
120-
setPendingAction(pendingAction)
121-
} catch (error) {
122-
logger.error('useDeepLinkWatcher: error parsing URL after login', {
123-
error,
124-
errorMessage:
125-
error instanceof Error ? error.message : String(error),
126-
url,
127-
})
120+
if (isWebCardanoLink(url)) {
121+
try {
122+
processedUrlsRef.current.add(url)
123+
const cardanoAction = parseCardanoLink(url)
124+
const pendingAction: PendingAction = {
125+
source: 'cardano',
126+
action: cardanoAction,
128127
}
128+
setPendingAction(pendingAction)
129+
} catch (error) {
130+
logger.error('useDeepLinkWatcher: error parsing URL after login', {
131+
error,
132+
errorMessage:
133+
error instanceof Error ? error.message : String(error),
134+
url,
135+
})
129136
}
130137
}
131138
}

mobile/src/ui/Counter/Counter.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const Counter = ({
4444

4545
{unitsText !== undefined && (
4646
<Text style={[a.body_2_md_medium, {color: p.primary_600}]}>
47-
{unitsText ?? ''}
47+
{` ${unitsText}`}
4848
</Text>
4949
)}
5050

@@ -56,7 +56,7 @@ export const Counter = ({
5656
: [a.body_2_md_regular, {color: p.primary_600}],
5757
]}
5858
>
59-
{closingText ?? ''}
59+
{` ${closingText}`}
6060
</Text>
6161
)}
6262
</Text>

0 commit comments

Comments
 (0)