-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(suite): reduce fetching new tokens time
- Loading branch information
Showing
3 changed files
with
17 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,22 @@ | ||
import { TokenInfo } from '@trezor/connect'; | ||
import * as accountUtils from '@suite-common/wallet-utils'; | ||
import { notificationsActions } from '@suite-common/toast-notifications'; | ||
import { accountsActions, updateFiatRatesThunk } from '@suite-common/wallet-core'; | ||
import { Timestamp, TokenAddress } from '@suite-common/wallet-types'; | ||
import { FiatCurrencyCode } from '@suite-common/suite-config'; | ||
import { accountsActions } from '@suite-common/wallet-core'; | ||
|
||
import { Dispatch } from 'src/types/suite'; | ||
import { Account } from 'src/types/wallet'; | ||
|
||
export const addToken = | ||
(account: Account, tokenInfo: TokenInfo[], localCurrency: FiatCurrencyCode) => | ||
(dispatch: Dispatch) => { | ||
dispatch( | ||
accountsActions.updateAccount({ | ||
...account, | ||
tokens: (account.tokens || []).concat(accountUtils.enhanceTokens(tokenInfo)), | ||
}), | ||
); | ||
export const addToken = (account: Account, tokenInfo: TokenInfo[]) => (dispatch: Dispatch) => { | ||
dispatch( | ||
accountsActions.updateAccount({ | ||
...account, | ||
tokens: (account.tokens || []).concat(accountUtils.enhanceTokens(tokenInfo)), | ||
}), | ||
); | ||
|
||
dispatch( | ||
updateFiatRatesThunk({ | ||
tickers: [ | ||
{ | ||
symbol: account.symbol, | ||
tokenAddress: tokenInfo[0].contract as TokenAddress, | ||
}, | ||
], | ||
localCurrency, | ||
rateType: 'current', | ||
fetchAttemptTimestamp: Date.now() as Timestamp, | ||
forceFetchToken: true, | ||
}), | ||
); | ||
|
||
dispatch( | ||
notificationsActions.addToast({ | ||
type: 'add-token-success', | ||
}), | ||
); | ||
}; | ||
dispatch( | ||
notificationsActions.addToast({ | ||
type: 'add-token-success', | ||
}), | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters