From 185bf11a8a6cc2c48bdbbe312f470f4b83bd6ced Mon Sep 17 00:00:00 2001 From: Marshall Rose Date: Fri, 26 Aug 2016 23:33:43 -0700 Subject: [PATCH 1/3] use different file name for development version i was running under both `/Applications` and `npm run watch/npm start` and had some unfortunate interactions --- app/ledger.js | 50 +++++++++++++++++++++++++++++--------------------- package.json | 2 +- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/app/ledger.js b/app/ledger.js index b7d3039f04c..6955a861072 100644 --- a/app/ledger.js +++ b/app/ledger.js @@ -53,13 +53,13 @@ const eventStore = require('../js/stores/eventStore') const rulesolver = require('./extensions/brave/content/scripts/pageInformation.js') // TBD: remove these post beta [MTR] -const logPath = path.join(app.getPath('userData'), 'ledger-log.json') -const publisherPath = path.join(app.getPath('userData'), 'ledger-publisher.json') -const scoresPath = path.join(app.getPath('userData'), 'ledger-scores.json') +const logPath = 'ledger-log.json' +const publisherPath = 'ledger-publisher.json' +const scoresPath = 'ledger-scores.json' // TBD: move these to secureState post beta [MTR] -const statePath = path.join(app.getPath('userData'), 'ledger-state.json') -const synopsisPath = path.join(app.getPath('userData'), 'ledger-synopsis.json') +const statePath = 'ledger-state.json' +const synopsisPath = 'ledger-synopsis.json' /* * ledger globals @@ -132,7 +132,7 @@ var boot = () => { if ((bootP) || (client)) return bootP = true - fs.access(statePath, fs.FF_OK, (err) => { + fs.access(pathName(statePath), fs.FF_OK, (err) => { if (!err) return if (err.code !== 'ENOENT') console.log('statePath read error: ' + err.toString()) @@ -337,11 +337,11 @@ var initialize = (onoff) => { cacheRuleSet(ledgerPublisher.rules) - fs.access(statePath, fs.FF_OK, (err) => { + fs.access(pathName(statePath), fs.FF_OK, (err) => { if (!err) { - if (clientOptions.verboseP) console.log('\nfound ' + statePath) + if (clientOptions.verboseP) console.log('\nfound ' + pathName(statePath)) - fs.readFile(statePath, (err, data) => { + fs.readFile(pathName(statePath), (err, data) => { var state if (err) return console.log('read error: ' + err.toString()) @@ -389,7 +389,7 @@ var enable = (onoff) => { } synopsis = new (ledgerPublisher.Synopsis)() - fs.readFile(synopsisPath, (err, data) => { + fs.readFile(pathName(synopsisPath), (err, data) => { if (clientOptions.verboseP) console.log('\nstarting up ledger publisher integration') if (err) { @@ -397,7 +397,7 @@ var enable = (onoff) => { return updatePublisherInfo() } - if (clientOptions.verboseP) console.log('\nfound ' + synopsisPath) + if (clientOptions.verboseP) console.log('\nfound ' + pathName(synopsisPath)) try { synopsis = new (ledgerPublisher.Synopsis)(data) } catch (ex) { @@ -411,13 +411,13 @@ var enable = (onoff) => { // Check if the add funds notification should be shown every 15 minutes notificationTimeout = setInterval(notifyAddFunds, msecs.minute * 15) - fs.readFile(publisherPath, (err, data) => { + fs.readFile(pathName(publisherPath), (err, data) => { if (err) { if (err.code !== 'ENOENT') console.log('publisherPath read error: ' + err.toString()) return } - if (clientOptions.verboseP) console.log('\nfound ' + publisherPath) + if (clientOptions.verboseP) console.log('\nfound ' + pathName(publisherPath)) try { data = JSON.parse(data) underscore.keys(data).sort().forEach((publisher) => { @@ -464,10 +464,10 @@ var updatePublisherInfo = () => { if (entries.length > 0) data[publisher] = entries }) - syncWriter(publisherPath, data, () => {}) - syncWriter(scoresPath, synopsis.allN(), () => {}) + syncWriter(pathName(publisherPath), data, () => {}) + syncWriter(pathName(scoresPath), synopsis.allN(), () => {}) - syncWriter(synopsisPath, synopsis, () => {}) + syncWriter(pathName(synopsisPath), synopsis, () => {}) publisherInfo.synopsis = synopsisNormalizer() if (publisherInfo._internal.debugP) { @@ -774,7 +774,7 @@ var callback = (err, result, delayTime) => { if ((i !== 0) && (i !== logs.length)) logs = logs.slice(i) if (result) entries.push({ who: 'callback', what: result, when: underscore.now() }) - syncWriter(logPath, entries, { flag: 'a' }, () => {}) + syncWriter(pathName(logPath), entries, { flag: 'a' }, () => {}) } if (err) { @@ -792,7 +792,7 @@ var callback = (err, result, delayTime) => { } cacheRuleSet(result.ruleset) - syncWriter(statePath, result, () => { run(delayTime) }) + syncWriter(pathName(statePath), result, () => { run(delayTime) }) } var roundtrip = (params, options, callback) => { @@ -883,7 +883,7 @@ var run = (delayTime) => { result = client.vote(winner) if (result) state = result }) - if (state) syncWriter(statePath, state, () => {}) + if (state) syncWriter(pathName(statePath), state, () => {}) } catch (ex) { console.log('ledger client error(2): ' + ex.toString() + (ex.stack ? ('\n' + ex.stack) : '')) } @@ -903,7 +903,7 @@ var run = (delayTime) => { if (!client) return console.log('\n\n*** MTR says this can\'t happen(1)... please tell him that he\'s wrong!\n\n') - if (client.sync(callback) === true) return run(random.randomInt({ min: 1, max: 10 * msecs.minute })) + if (client.sync(callback) === true) return run(0) }, delayTime) } @@ -1023,7 +1023,7 @@ var setPaymentInfo = (amount) => { client.setBraveryProperties(bravery, (err, result) => { if (err) return console.log('ledger setBraveryProperties: ' + err.toString()) - if (result) syncWriter(statePath, result, () => {}) + if (result) syncWriter(pathName(statePath), result, () => {}) }) if (ledgerInfo.created) getPaymentInfo() } @@ -1079,6 +1079,14 @@ var syncWriter = (path, obj, options, cb) => { }) } +const pathSuffix = (process.env.NODE_ENV === 'development') ? '-dev' : '' + +var pathName = (name) => { + var parts = path.parse(name) + + return path.join(app.getPath('userData'), parts.name + pathSuffix + parts.ext) +} + /** * UI controller functionality */ diff --git a/package.json b/package.json index c6def431126..3aae6c7994e 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "keytar": "^3.0.0", "l20n": "^3.5.1", "ledger-balance": "^0.8.46", - "ledger-client": "^0.8.49", + "ledger-client": "^0.8.50", "ledger-publisher": "^0.8.47", "lru_cache": "^1.0.0", "random-lib": "2.1.0", From 08e7ddcaf87cf1cbb76e2942040545b0bba2c77d Mon Sep 17 00:00:00 2001 From: Marshall Rose Date: Fri, 26 Aug 2016 23:46:34 -0700 Subject: [PATCH 2/3] standard 8.0 is prefers to --- js/about/preferences.js | 6 +++--- js/components/findbar.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/js/about/preferences.js b/js/about/preferences.js index 3c78fbdfd5c..14cc55c7a99 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -556,11 +556,11 @@ class PaymentsTab extends ImmutableComponent { return

-
+
-
+
-
+
} diff --git a/js/components/findbar.js b/js/components/findbar.js index b6048b58a9c..1acc4caae01 100644 --- a/js/components/findbar.js +++ b/js/components/findbar.js @@ -177,7 +177,7 @@ class FindBar extends ImmutableComponent { return
- + { this.searchInput = node }} @@ -185,7 +185,7 @@ class FindBar extends ImmutableComponent { onChange={this.onChange} value={this.searchString} /> + onClick={this.onClear} />
{findMatchText}
Date: Fri, 26 Aug 2016 23:58:43 -0700 Subject: [PATCH 3/3] Revert "standard 8.0 is prefers to " This reverts commit 08e7ddcaf87cf1cbb76e2942040545b0bba2c77d. --- js/about/preferences.js | 6 +++--- js/components/findbar.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/js/about/preferences.js b/js/about/preferences.js index 14cc55c7a99..3c78fbdfd5c 100644 --- a/js/about/preferences.js +++ b/js/about/preferences.js @@ -556,11 +556,11 @@ class PaymentsTab extends ImmutableComponent { return

-
+
-
+
-
+
} diff --git a/js/components/findbar.js b/js/components/findbar.js index 1acc4caae01..b6048b58a9c 100644 --- a/js/components/findbar.js +++ b/js/components/findbar.js @@ -177,7 +177,7 @@ class FindBar extends ImmutableComponent { return
- + { this.searchInput = node }} @@ -185,7 +185,7 @@ class FindBar extends ImmutableComponent { onChange={this.onChange} value={this.searchString} /> + onClick={this.onClear}>
{findMatchText}