mirror of
https://github.com/trezor/trezor-wallet
synced 2024-12-30 19:00:53 +00:00
update fee in reducer only if changed
This commit is contained in:
parent
6d78e3a8f7
commit
3ae45ddd7e
@ -16,6 +16,7 @@ export type BlockchainAction = {
|
||||
type: typeof BLOCKCHAIN.READY,
|
||||
} | {
|
||||
type: typeof BLOCKCHAIN.UPDATE_FEE,
|
||||
shortcut: string,
|
||||
fee: string,
|
||||
}
|
||||
|
||||
|
@ -23,16 +23,22 @@ export const subscribe = (network: string): PromiseAction<void> => async (dispat
|
||||
};
|
||||
|
||||
|
||||
export const onBlockMined = (network: string): PromiseAction<void> => async (dispatch: Dispatch): Promise<void> => {
|
||||
export const onBlockMined = (network: string): PromiseAction<void> => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||
const fee = await TrezorConnect.blockchainGetFee({
|
||||
coin: network,
|
||||
});
|
||||
if (!fee.success) return;
|
||||
|
||||
dispatch({
|
||||
type: BLOCKCHAIN.UPDATE_FEE,
|
||||
fee: fee.payload,
|
||||
});
|
||||
const blockchain = getState().blockchain.find(b => b.shortcut === network);
|
||||
if (!blockchain) return;
|
||||
|
||||
if (fee.payload !== blockchain.fee) {
|
||||
dispatch({
|
||||
type: BLOCKCHAIN.UPDATE_FEE,
|
||||
shortcut: network,
|
||||
fee: fee.payload,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const onNotification = (payload: $ElementType<BlockchainNotification, 'payload'>): PromiseAction<void> => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||
|
Loading…
Reference in New Issue
Block a user