From e0d5db174014372f3e4aa9cc917bfe2f957c1b47 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Sun, 12 Mar 2017 11:22:46 +0100 Subject: [PATCH] Review fixes --- app/common/lib/ledgerUtil.js | 28 ++++++++++++++ .../preferences/payment/advancedSettings.js | 1 - .../preferences/payment/enabledContent.js | 37 ++----------------- .../components/preferences/payment/history.js | 4 +- less/about/preferences.less | 1 - 5 files changed, 34 insertions(+), 37 deletions(-) diff --git a/app/common/lib/ledgerUtil.js b/app/common/lib/ledgerUtil.js index 36f2749ea5e..6f3b7fb7a58 100644 --- a/app/common/lib/ledgerUtil.js +++ b/app/common/lib/ledgerUtil.js @@ -78,3 +78,31 @@ module.exports.formattedDateFromTimestamp = (timestamp) => { moment.locale(navigator.language) return moment(new Date(timestamp)).format('YYYY-MM-DD') } + +module.exports.walletStatus = (ledgerData) => { + let status = {} + + if (ledgerData.get('error')) { + status.id = 'statusOnError' + } else if (ledgerData.get('created')) { + const transactions = ledgerData.get('transactions') + const pendingFunds = Number(ledgerData.get('unconfirmed') || 0) + + if (pendingFunds + Number(ledgerData.get('balance') || 0) < + 0.9 * Number(ledgerData.get('btc') || 0)) { + status.id = 'insufficientFundsStatus' + } else if (pendingFunds > 0) { + status.id = 'pendingFundsStatus' + status.args = {funds: module.exports.btcToCurrencyString(pendingFunds, ledgerData)} + } else if (transactions && transactions.size > 0) { + status.id = 'defaultWalletStatus' + } else { + status.id = 'createdWalletStatus' + } + } else if (ledgerData.get('creating')) { + status.id = 'creatingWalletStatus' + } else { + status.id = 'createWalletStatus' + } + return status +} diff --git a/app/renderer/components/preferences/payment/advancedSettings.js b/app/renderer/components/preferences/payment/advancedSettings.js index c477f28a4a8..fb81cc9bf07 100644 --- a/app/renderer/components/preferences/payment/advancedSettings.js +++ b/app/renderer/components/preferences/payment/advancedSettings.js @@ -27,7 +27,6 @@ class AdvancedSettingsContent extends ImmutableComponent { const minDuration = this.props.ledgerData.getIn(['synopsisOptions', 'minDuration']) const minPublisherVisits = this.props.ledgerData.getIn(['synopsisOptions', 'minPublisherVisits']) - // TODO translate seconds, minute and visits return
diff --git a/app/renderer/components/preferences/payment/enabledContent.js b/app/renderer/components/preferences/payment/enabledContent.js index a74d9653f2d..fe7966def6b 100644 --- a/app/renderer/components/preferences/payment/enabledContent.js +++ b/app/renderer/components/preferences/payment/enabledContent.js @@ -6,7 +6,7 @@ const React = require('react') const {StyleSheet, css} = require('aphrodite') // util -const {btcToCurrencyString, formattedTimeFromNow} = require('../../../../common/lib/ledgerUtil') +const {btcToCurrencyString, formattedTimeFromNow, walletStatus} = require('../../../../common/lib/ledgerUtil') const {l10nErrorText} = require('../../../../common/lib/httpUtil') const {changeSetting} = require('../../../lib/settingsUtil') @@ -102,35 +102,6 @@ class EnabledContent extends ImmutableComponent { return l10nErrorText(errorCode) } - walletStatus () { - const ledgerData = this.props.ledgerData - let status = {} - - if (ledgerData.get('error')) { - status.id = 'statusOnError' - } else if (ledgerData.get('created')) { - const transactions = ledgerData.get('transactions') - const pendingFunds = Number(ledgerData.get('unconfirmed') || 0) - - if (pendingFunds + Number(ledgerData.get('balance') || 0) < - 0.9 * Number(ledgerData.get('btc') || 0)) { - status.id = 'insufficientFundsStatus' - } else if (pendingFunds > 0) { - status.id = 'pendingFundsStatus' - status.args = {funds: btcToCurrencyString(pendingFunds, ledgerData)} - } else if (transactions && transactions.size > 0) { - status.id = 'defaultWalletStatus' - } else { - status.id = 'createdWalletStatus' - } - } else if (ledgerData.get('creating')) { - status.id = 'creatingWalletStatus' - } else { - status.id = 'createWalletStatus' - } - return status - } - createWallet () { const ledgerData = this.props.ledgerData if (!ledgerData.get('created')) { @@ -197,7 +168,7 @@ class EnabledContent extends ImmutableComponent { render () { const ledgerData = this.props.ledgerData - const walletStatus = this.walletStatus() + const walletStatusText = walletStatus(ledgerData) return
@@ -249,8 +220,8 @@ class EnabledContent extends ImmutableComponent {
{this.nextReconcileMessage()} diff --git a/app/renderer/components/preferences/payment/history.js b/app/renderer/components/preferences/payment/history.js index 165a48c5ff8..f571dedccea 100644 --- a/app/renderer/components/preferences/payment/history.js +++ b/app/renderer/components/preferences/payment/history.js @@ -114,7 +114,7 @@ class HistoryFooter extends ImmutableComponent { } return
-
+