Page MenuHomePhabricator

[Cashtab] [WS Update Engine Part 2] Deprecate useAsyncTimeout in favor of useInterval hook to support dynamic changes wallet utxo refresh interval
ClosedPublic

Authored by bytesofman on Jun 22 2022, 23:13.

Details

Summary

T2447

Depends on D11656

Part 2 (of 4 planned) stacked diff for converting Cashtab from a static refresh rate to an on-demand refresh rate depending on Websocket transaction messages

This diff deprecates the useAsyncTimeout custom hook in favor of the useInterval custom hook described at https://overreacted.io/making-setinterval-declarative-with-react-hooks/. This custom hook has the benefit of adjusting the interval on the fly. In testing, useAsyncTimeout did not work with this feature.

useAsyncTimeout as a function predates the Cashtab Mint fork. So, while the benefit of this useInterval function is clear, keep in mind https://en.wiktionary.org/wiki/Chesterton's_fence

Reviewing useAsyncTimeout, the custom hook was necessary due to the way React handles state compared to the useInterval and setTimeout APIs.

Test Plan

npm start
Confirm wallet utxo set and balance updates on received XEC tx
Confirm wallet utxo set and balance updates on received eToken tx
Mint an eToken
Change wallets
Run the same tests

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable