From 5ae0dae3db0a82ae484336b89e63aecea40a4c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Thu, 15 Nov 2018 17:39:46 +0100 Subject: [PATCH 1/2] Fix estetic glitch that display "Paused" when a sync is disrupted --- src/reducers/accounts.js | 10 +++++++++- src/reducers/bridgeSync.js | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/reducers/accounts.js b/src/reducers/accounts.js index 82075e9e..1d5d202d 100644 --- a/src/reducers/accounts.js +++ b/src/reducers/accounts.js @@ -6,6 +6,7 @@ import accountModel from 'helpers/accountModel' import logger from 'logger' import type { Account, AccountRaw } from '@ledgerhq/live-common/lib/types' import { OUTDATED_CONSIDERED_DELAY, DEBUG_SYNC } from 'config/constants' +import { currenciesStatusSelector, getIsCurrencyDown } from './currenciesStatus' export type AccountsState = Account[] const state: AccountsState = [] @@ -60,7 +61,14 @@ const handlers: Object = { export const accountsSelector = (state: { accounts: AccountsState }): Account[] => state.accounts -export const isUpToDateSelector = createSelector(accountsSelector, accounts => +export const activeAccountsSelector = createSelector( + accountsSelector, + currenciesStatusSelector, + (accounts, currenciesStatus) => + accounts.filter(a => !getIsCurrencyDown(currenciesStatus, a.currency)), +) + +export const isUpToDateSelector = createSelector(activeAccountsSelector, accounts => accounts.every(a => { const { lastSyncDate } = a const { blockAvgTime } = a.currency diff --git a/src/reducers/bridgeSync.js b/src/reducers/bridgeSync.js index b7895a4f..6390de8c 100644 --- a/src/reducers/bridgeSync.js +++ b/src/reducers/bridgeSync.js @@ -3,7 +3,7 @@ import { createSelector } from 'reselect' import { handleActions } from 'redux-actions' import type { State } from 'reducers' -import { accountsSelector } from './accounts' +import { activeAccountsSelector } from './accounts' export type AsyncState = { pending: boolean, @@ -45,7 +45,7 @@ export const syncStateLocalSelector = ( ) => bridgeSync.syncs[accountId] || nothingState export const globalSyncStateSelector = createSelector( - accountsSelector, + activeAccountsSelector, bridgeSyncSelector, (accounts, bridgeSync) => { const globalSyncState: AsyncState = { From 952f002d5a959d0ec4c707456c32903112c15fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Fri, 16 Nov 2018 15:20:51 +0100 Subject: [PATCH 2/2] QRCode exporter uses activeAccountsSelector --- src/components/QRCodeExporter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/QRCodeExporter.js b/src/components/QRCodeExporter.js index 7b994f0e..91e3b370 100644 --- a/src/components/QRCodeExporter.js +++ b/src/components/QRCodeExporter.js @@ -5,14 +5,14 @@ import { Buffer } from 'buffer' import { createStructuredSelector } from 'reselect' import { connect } from 'react-redux' -import { accountsSelector } from 'reducers/accounts' +import { activeAccountsSelector } from 'reducers/accounts' import { exportSettingsSelector } from 'reducers/settings' import { encode } from '@ledgerhq/live-common/lib/cross' import { dataToFrames } from 'qrloop/exporter' import QRCode from './base/QRCode' const mapStateToProps = createStructuredSelector({ - accounts: accountsSelector, + accounts: activeAccountsSelector, settings: exportSettingsSelector, })