Skip to content

Commit 82a607a

Browse files
committed
feat: keep hardware wallet alert first in custom amount alerts
1 parent b62ffaf commit 82a607a

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

app/components/Views/confirmations/hooks/transactions/useTransactionCustomAmountAlerts.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,16 @@ export function useTransactionCustomAmountAlerts({
7373
});
7474
}, [confirmationAlerts, isInputChanged, isKeyboardVisible]);
7575

76-
const alerts = useMemo(
77-
() => [...pendingTokenAlerts, ...filteredAlerts],
78-
[filteredAlerts, pendingTokenAlerts],
79-
);
76+
const alerts = useMemo(() => {
77+
const merged = [...pendingTokenAlerts, ...filteredAlerts];
78+
79+
// The hardware wallet alert can only be fixed by switching accounts, so
80+
// its message takes priority over amount-level alerts.
81+
return [
82+
...merged.filter((a) => a.key === AlertKeys.MMPayHardwareAccount),
83+
...merged.filter((a) => a.key !== AlertKeys.MMPayHardwareAccount),
84+
];
85+
}, [filteredAlerts, pendingTokenAlerts]);
8086

8187
const firstAlert = alerts?.[0];
8288

0 commit comments

Comments
 (0)