From d72b629cd534b26ff6ffc9acd5069427908ccf68 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Mon, 2 Oct 2017 05:40:21 +0200 Subject: [PATCH] Addresses reviews comments 2 --- app/browser/api/ledger.js | 38 +++++++------------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/app/browser/api/ledger.js b/app/browser/api/ledger.js index a25ad3b9038..95cf6546554 100644 --- a/app/browser/api/ledger.js +++ b/app/browser/api/ledger.js @@ -15,7 +15,7 @@ const qr = require('qr-image') const underscore = require('underscore') const tldjs = require('tldjs') const urlFormat = require('url').format -const queryString = require('queryString') +const queryString = require('querystring') const levelUp = require('level') const random = require('random-lib') const uuid = require('uuid') @@ -51,8 +51,8 @@ let bootP let quitP let notificationPaymentDoneMessage const _internal = { - verboseP: true, - debugP: true, + verboseP: process.env.LEDGER_VERBOSE || true, + debugP: process.env.LEDGER_DEBUG || true, ruleset: { raw: [], cooked: [] @@ -102,6 +102,8 @@ const fileTypes = { jpeg: new Buffer([0xff, 0xd8, 0xff]), png: new Buffer([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]) } +const minimumVisitTimeDefault = 8 * 1000 +const nextAddFoundsTime = 3 * miliseconds.day let signatureMax = 0 underscore.keys(fileTypes).forEach((fileType) => { @@ -1033,7 +1035,7 @@ const initSynopsis = (state) => { state = ledgerState.saveSynopsis(state, null, synopsis.options) let value = getSetting(settings.PAYMENTS_MINIMUM_VISIT_TIME) if (!value) { - value = 8 * 1000 + value = minimumVisitTimeDefault appActions.changeSetting(settings.PAYMENTS_MINIMUM_VISIT_TIME, value) } @@ -1179,7 +1181,7 @@ const showNotificationReviewPublishers = (nextTime) => { } const showNotificationAddFunds = () => { - const nextTime = new Date().getTime() + (3 * miliseconds.day) + const nextTime = new Date().getTime() + nextAddFoundsTime appActions.changeSetting(settings.PAYMENTS_NOTIFICATION_ADD_FUNDS_TIMESTAMP, nextTime) appActions.showNotification({ @@ -1435,32 +1437,6 @@ const updateLedgerInfo = (state) => { state = ledgerState.setInfoProp(state, 'buyMaximumUSD', false) } - // TODO remove when BAT is implemented, we don't need this for BAT - /* - if ((client) && (now > ledgerInfo._internal.geoipExpiry)) { - ledgerInfo._internal.geoipExpiry = now + (5 * miliseconds.minute) - - if (!ledgerGeoIP) ledgerGeoIP = require('ledger-geoip') - return ledgerGeoIP.getGeoIP(client.options, (err, provider, result) => { - if (err) console.warn('ledger geoip warning: ' + JSON.stringify(err, null, 2)) - if (result) ledgerInfo.countryCode = result - - ledgerInfo.exchangeInfo = ledgerInfo._internal.exchanges[ledgerInfo.countryCode] - - if (now <= ledgerInfo._internal.exchangeExpiry) return updateLedgerInfo() - - ledgerInfo._internal.exchangeExpiry = now + miliseconds.day - roundtrip({ path: '/v1/exchange/providers' }, client.options, (err, response, body) => { - if (err) console.error('ledger exchange error: ' + JSON.stringify(err, null, 2)) - - ledgerInfo._internal.exchanges = body || {} - ledgerInfo.exchangeInfo = ledgerInfo._internal.exchanges[ledgerInfo.countryCode] - updateLedgerInfo() - }) - }) - } - */ - return state }