Skip to content
This repository has been archived by the owner. It is now read-only.

supersede synopsis-related PRs to get a clean merge #4194

Merged
merged 1 commit into from Sep 22, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -110,7 +110,24 @@ let notificationTimeout = null
const doAction = (action) => {
var i, publisher

/* TBD: handle
{ actionType: "window-set-blocked-by"
, frameProps:
{ audioPlaybackActive: true
...
}
, ...
}
*/
if (publisherInfo._internal.verboseP) {
console.log('\napplication event: ' + JSON.stringify(underscore.pick(action, [ 'actionType', 'key' ]), null, 2))
}
switch (action.actionType) {
case appConstants.APP_IDLE_STATE_CHANGED:
visit('NOOP', underscore.now(), null)
break

case appConstants.APP_CHANGE_SETTING:
if (action.key === settings.PAYMENTS_ENABLED) return initialize(action.value)
if (action.key === settings.PAYMENTS_CONTRIBUTION_AMOUNT) return setPaymentInfo(action.value)
@@ -456,10 +473,30 @@ var enable = (onoff) => {

synopsis = new (ledgerPublisher.Synopsis)()
fs.readFile(pathName(synopsisPath), (err, data) => {
var initSynopsis = () => {
// cf., the `Synopsis` constructor, https://github.com/brave/ledger-publisher/blob/master/index.js#L167
if (process.env.NODE_ENV === 'test') {
synopsis.options.minDuration = 0
synopsis.options.minPublisherDuration = 0
synopsis.options.minPublisherVisits = 0
} else {
if (process.env.LEDGER_PUBLISHER_VISIT_DURATION) {
synopsis.options.minDuration = ledgerClient.prototype.numbion(process.env.LEDGER_PUBLISHER_VISIT_DURATION)
}
if (process.env.LEDGER_PUBLISHER_MIN_DURATION) {
synopsis.options.minPublisherDuration = ledgerClient.prototype.numbion(process.env.LEDGER_PUBLISHER_MIN_DURATION)
}
if (process.env.LEDGER_PUBLISHER_MIN_VISITS) {
synopsis.options.minPublisherVisits = ledgerClient.prototype.numbion(process.env.LEDGER_PUBLISHER_MIN_VISITS)
}
}
}

if (publisherInfo._internal.verboseP) console.log('\nstarting up ledger publisher integration')

if (err) {
if (err.code !== 'ENOENT') console.log('synopsisPath read error: ' + err.toString())
initSynopsis()
return updatePublisherInfo()
}

@@ -469,22 +506,7 @@ var enable = (onoff) => {
} catch (ex) {
console.log('synopsisPath parse error: ' + ex.toString())
}
// cf., the `Synopsis` constructor, https://github.com/brave/ledger-publisher/blob/master/index.js#L167
if (process.env.NODE_ENV === 'test') {
synopsis.options.minDuration = 0
synopsis.options.minPublisherDuration = 0
synopsis.options.minPublisherVisits = 0
} else {
if (process.env.LEDGER_PUBLISHER_VISIT_DURATION) {
synopsis.options.minDuration = ledgerClient.prototype.numbion(process.env.LEDGER_PUBLISHER_VISIT_DURATION)
}
if (process.env.LEDGER_PUBLISHER_MIN_DURATION) {
synopsis.options.minPublisherDuration = ledgerClient.prototype.numbion(process.env.LEDGER_PUBLISHER_MIN_DURATION)
}
if (process.env.LEDGER_PUBLISHER_MIN_VISITS) {
synopsis.options.minPublisherVisits = ledgerClient.prototype.numbion(process.env.LEDGER_PUBLISHER_MIN_VISITS)
}
}
initSynopsis()
underscore.keys(synopsis.publishers).forEach((publisher) => {
if (synopsis.publishers[publisher].faviconURL === null) delete synopsis.publishers[publisher].faviconURL
})
@@ -1291,11 +1313,8 @@ var syncWriter = (path, obj, options, cb) => {

var pathName = (name) => {
var parts = path.parse(name)
var basePath = process.env.NODE_ENV === 'test'
? path.join(process.env.HOME, '.brave-test-ledger')
: app.getPath('userData')

return path.join(basePath, parts.name + parts.ext)
return path.join(app.getPath('userData'), parts.name + parts.ext)
}

/**
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.