Skip to content

Commit c2a5e22

Browse files
committed
Keep the expiry message on screen with its own slider gate
The expiry error was written into the shared error state as a plain-send one, so entering swap-send retracted it while the expiry flag stayed set: a disabled slider with nothing on screen saying why. The message belongs to the REQUEST, so the plain-send clear now refuses it. A source wallet or asset switch retires whatever error is showing, for the same reason it already retires the toggle and the learned route capabilities.
1 parent b0a8e4f commit c2a5e22

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

‎src/components/scenes/SendScene2.tsx‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,16 @@ const SendComponent: React.FC<Props> = props => {
282282
)
283283
const [expireDate, setExpireDate] = useState<Date | undefined>(initExpireDate)
284284
/** Whether the payment request's own countdown has run out. */
285-
const [addressExpired, setAddressExpired] = useState<boolean>(false)
285+
const [addressExpired, setAddressExpiredState] = useState<boolean>(false)
286+
/**
287+
* Mirror of `addressExpired` for the error-owner helpers below, which are
288+
* also called from async effects holding an older render's closure.
289+
*/
290+
const addressExpiredRef = React.useRef<boolean>(false)
291+
const setAddressExpired = (value: boolean): void => {
292+
addressExpiredRef.current = value
293+
setAddressExpiredState(value)
294+
}
286295
const [error, setError] = useState<unknown | undefined>(undefined)
287296
const [edgeTransaction, setEdgeTransaction] =
288297
useState<EdgeTransaction | null>(null)
@@ -382,6 +391,10 @@ const SendComponent: React.FC<Props> = props => {
382391
/** The converse: retract a plain-send error without touching a swap one. */
383392
const clearPlainSendError = (): void => {
384393
if (swapErrorShown.current) return
394+
// The expiry message belongs to the REQUEST, not to either send mode, and
395+
// the slider stays disabled on it either way. Retracting it here left the
396+
// user looking at a dead slider with nothing on screen explaining why.
397+
if (addressExpiredRef.current) return
385398
setError(undefined)
386399
}
387400

@@ -1342,6 +1355,12 @@ const SendComponent: React.FC<Props> = props => {
13421355
setRateStarvedFallback(false)
13431356
setStealth(false)
13441357
setRouteCaps({})
1358+
// The message describes the pair and wallet the user just left, the
1359+
// same reason the toggle and the route caps go. Through the owners,
1360+
// so `swapErrorShown` does not survive the wallet it belonged to.
1361+
clearSwapError()
1362+
setAddressExpired(false)
1363+
clearPlainSendError()
13451364
// The recipients go with them, EVERY one of them. Clearing the
13461365
// destination CHAIN while leaving an address behind drops the scene
13471366
// back into plain-send mode still displaying a foreign-chain

0 commit comments

Comments
 (0)