diff --git a/src/actions/BlockchainActions.js b/src/actions/BlockchainActions.js index 5393813e..9dde3442 100644 --- a/src/actions/BlockchainActions.js +++ b/src/actions/BlockchainActions.js @@ -16,6 +16,7 @@ export type BlockchainAction = { type: typeof BLOCKCHAIN.READY, } | { type: typeof BLOCKCHAIN.UPDATE_FEE, + shortcut: string, fee: string, } diff --git a/src/actions/ripple/BlockchainActions.js b/src/actions/ripple/BlockchainActions.js index 14f7e020..3f4cf884 100644 --- a/src/actions/ripple/BlockchainActions.js +++ b/src/actions/ripple/BlockchainActions.js @@ -23,16 +23,22 @@ export const subscribe = (network: string): PromiseAction => async (dispat }; -export const onBlockMined = (network: string): PromiseAction => async (dispatch: Dispatch): Promise => { +export const onBlockMined = (network: string): PromiseAction => async (dispatch: Dispatch, getState: GetState): Promise => { 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): PromiseAction => async (dispatch: Dispatch, getState: GetState): Promise => {