HomePhabricator

[Cashtab] contactList PropType error patch

Description

[Cashtab] contactList PropType error patch

Summary:
In useWallet.js at line 41, contactList is initialized as a boolean, instead of an empty array. Related to task T2515.

From Joey:

After reviewing the code -- this looks good and I think it is a good approach. However, please provide an explanation as to why it's okay to not initialize contactList as false.

There is no logic that I can find that depends on contactList being a boolean value. When loadContactList runs, if the contactList is not found in localStorage, it will be set as an empty array containing an empty object.

For example, wallet is initialized as false -- and this is critical to the logic of how Cashtab functions, i.e. this is how it knows whether or not the user has a wallet.

Looking through with grep -r 'contactList' src/, I was not able to find similar logic where contactList is treated as a boolean before it is initialized. However, please confirm this, and please add this discussion to the diff.

Although I also could not find an instance of Cashtab requiring contactList to be initialized as a boolean, an alternative option to preserve this logic would be to use the oneOfType Proptype and include boolean as an acceptable Proptype. With that being said, having tested the various contactList actions and reviewing the code, it seems certain that it is an unnecessary inclusion; so in the spirit of writing less code, I believe it is best to initialize contactList as an empty array containing an empty object.

Test Plan:
cd web/cashtab && npm start
Open dev tools
Observe that the contactList error does not appear in the console

Reviewers: bytesofman, #bitcoin_abc

Reviewed By: bytesofman, #bitcoin_abc

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

Details

Provenance
kieran709Authored on Jul 7 2022, 17:58
kieran709Pushed on Jul 11 2022, 12:49
Reviewer
Restricted Project
Differential Revision
D11730: [Cashtab] contactList PropType error patch
Parents
rABCdc71c7aa79c1: [cashtab-components] update storybook logo
Branches
Unknown
Tags
Unknown