mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2025-12-26 18:34:26 +01:00
Merge pull request #127 from MutinyWallet/optimistic-balance
optimistic balance fetching at setup
This commit is contained in:
@@ -87,7 +87,9 @@ export const Provider: ParentComponent = (props) => {
|
||||
try {
|
||||
setState({ wallet_loading: true })
|
||||
const mutinyWallet = await setupMutinyWallet(settings)
|
||||
setState({ mutiny_wallet: mutinyWallet, wallet_loading: false })
|
||||
// Get balance optimistically
|
||||
const balance = await mutinyWallet.get_balance();
|
||||
setState({ mutiny_wallet: mutinyWallet, wallet_loading: false, balance })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
@@ -111,8 +113,8 @@ export const Provider: ParentComponent = (props) => {
|
||||
if (state.mutiny_wallet && !state.is_syncing) {
|
||||
setState({ is_syncing: true })
|
||||
await state.mutiny_wallet?.sync()
|
||||
const balance = await state.mutiny_wallet?.get_balance();
|
||||
setState({ balance, last_sync: Date.now() })
|
||||
const newBalance = await state.mutiny_wallet?.get_balance();
|
||||
setState({ balance: newBalance, last_sync: Date.now() })
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
Reference in New Issue
Block a user