hathor-wallet-mobile icon indicating copy to clipboard operation
hathor-wallet-mobile copied to clipboard

refactor: load the tokens asynchronously after HTR history and balance is loaded

Open andreabadesso opened this issue 2 years ago • 2 comments

Currently, on the wallet-service facade, we wait until we load the balance and tx_history of all the tokens the user has ever interacted with before showing the home screen

We should refactor it so we load only HTR (or the token registered as default for the wallet) balance and tx_history and load the rest asynchronously, with a loading icon on the registered tokens

andreabadesso avatar Jul 22 '22 15:07 andreabadesso

Not sure if it would be a bigger task, but I feel we should change our wallets to assume things will be loaded on demand (async). In this case, the wallet would need to load only the network (e.g., mainnet) and the list of tokens and their balances. When users open a token screen, then the wallet will load that given information (including the history).

Internally, I think the screen can request the data and receive a promise. The screen can also pass a callback function to update screen with the progress.

As a transition, our wallets currently preload everything. So the promises will be immediately resolved with the requested data.

The wallet-service facade will be the first one to really load the data asynchronously.

What do you think?

@andreabadesso @pedroferreira1

msbrogli avatar Jul 22 '22 15:07 msbrogli

I'm thinking about both solutions. With the APIs we have now, I believe loading the balance of all tokens would be a bad idea, given that we would need to make one request for each token.

If we improve the API in the wallet service to return a list of tokens with the balance (paginated probably), we could implement Marcelo's proposal and would be great in my opinion.

pedroferreira1 avatar Jul 22 '22 16:07 pedroferreira1

This is done after the refactor we did with redux-saga, so closing it

andreabadesso avatar Mar 29 '23 15:03 andreabadesso