HomePhabricator

[Cashtab] Make sure selectedOffer cannot be undefined after a ws update

Description

[Cashtab] Make sure selectedOffer cannot be undefined after a ws update

Summary:
We update activeOffers every time there is an agora action on the websocket subscription. However, if that action resulted in an offer being canceled or fully accepted, it is possible the selected offer will be undefined after activeOffers are updated.

We want selectedIndex to always be zero when active offers are updated. This also ensures the spot offer is selected by default.

Test Plan:
npm test

Find a token pair with 1 offer. Create another offer higher than spot. Select it. Cancel the offer.

We do not get a white screen app failure like we do now.

Not (easily) tested directly as I have not managed to mock ws events in existing tests.

Reviewers: #bitcoin_abc, emack

Reviewed By: #bitcoin_abc, emack

Differential Revision: https://reviews.bitcoinabc.org/D17571

Details

Provenance
bytesofmanAuthored on Jan 21 2025, 11:33
bytesofmanPushed on Jan 21 2025, 21:03
Reviewer
Restricted Project
Differential Revision
D17571: [Cashtab] Make sure selectedOffer cannot be undefined after a ws update
Parents
rABCb7a52c79e63d: [electrum] refactor: introduce a Wordlist class for seed phrases
Branches
Unknown
Tags
Unknown