Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

a few minor things #3554

Merged
merged 3 commits into from
Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/extensions/brave/content/scripts/pageInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@
expr['arguments'].forEach((argument) => { args.push(traverse(argument)) })
return value[traverse(op1.property, true)].apply(value, args)

case 'NewExpression':
op1 = expr.callee
if (op1.type !== 'Identifier') throw new Error('unexpected callee: ' + op1.type)
if (op1.name !== 'Set') throw new Error('only new Set(...) is allowed, not new ' + op1.name)
args = []
expr['arguments'].forEach((argument) => { args.push(traverse(argument)) })
if (args.length > 1) throw new Error('Set(...) takes at most one argument')
return new Set(args[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't this already reviewed in #3545 by @BrendanEich ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, as noted in the PR, it's included here as well.


case 'ConditionalExpression':
return (traverse(expr.test) ? traverse(expr.consequent) : traverse(expr.alternate))

Expand Down
17 changes: 10 additions & 7 deletions app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,6 @@ eventStore.addChangeListener(() => {
var entry, faviconURL, publisher
var location = page.url

/*
console.log('\npage=' + JSON.stringify(page, null, 2))
*/
if ((location.match(/^about/)) || ((locations[location]) && (locations[location].publisher))) return

if (!page.publisher) {
Expand Down Expand Up @@ -403,6 +400,7 @@ var enable = (onoff) => {
} catch (ex) {
console.log('synopsisPath parse error: ' + ex.toString())
}
if (process.env.NODE_ENV === 'test') synopsis.options.minDuration = 0
underscore.keys(synopsis.publishers).forEach((publisher) => {
if (synopsis.publishers[publisher].faviconURL === null) delete synopsis.publishers[publisher].faviconURL
})
Expand Down Expand Up @@ -467,16 +465,19 @@ var updatePublisherInfo = () => {
syncWriter(pathName(publisherPath), data, () => {})
syncWriter(pathName(scoresPath), synopsis.allN(), () => {})

if (synopsis.options.minDuration === 0) synopsis.options.minDuration = 8 * msecs.second
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it set to 8s here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because that is the actual default value, and when the synopsis is written out, i don't want it to be zero, so that when someone starts the browser without process.env.NODE_ENV being test, they won't get surprised... but, i see an easier fix. please stand by.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diracdeltas - i think the latest commit simplifies things.

syncWriter(pathName(synopsisPath), synopsis, () => {})
publisherInfo.synopsis = synopsisNormalizer()

if (publisherInfo._internal.debugP) {
/*
data = []
publisherInfo.synopsis.forEach((entry) => {
data.push(underscore.extend(underscore.omit(entry, [ 'faviconURL' ]), { faviconURL: entry.faviconURL && '...' }))
})

console.log('\nupdatePublisherInfo: ' + JSON.stringify(data, null, 2))
*/
}

appActions.updatePublisherInfo(underscore.omit(publisherInfo, [ '_internal' ]))
Expand Down Expand Up @@ -584,9 +585,10 @@ var visit = (location, timestamp) => {

if (!synopsis) return

/*
console.log('locations[' + currentLocation + ']=' + JSON.stringify(locations[currentLocation], null, 2))
*/
if (publisherInfo._internal.debugP) {
console.log('locations[' + currentLocation + ']=' + JSON.stringify(locations[currentLocation], null, 2) +
' duration=' + (timestamp - currentTimestamp) + ' msec')
}
if ((location === currentLocation) || (!locations[currentLocation])) return

publisher = locations[currentLocation].publisher
Expand All @@ -596,6 +598,7 @@ var visit = (location, timestamp) => {
publishers[publisher][currentLocation] = timestamp

duration = timestamp - currentTimestamp
if (publisherInfo._internal.debugP) console.log('\nadd publisher ' + publisher + ': ' + duration + ' msec')
synopsis.addPublisher(publisher, duration)
updatePublisherInfo()
}
Expand Down Expand Up @@ -795,7 +798,7 @@ var callback = (err, result, delayTime) => {
}

if (err) {
console.log('ledger client error(1): ' + err.toString() + (err.stack ? ('\n' + err.stack) : ''))
console.log('ledger client error(1): ' + JSON.stringify(err, null, 2) + (err.stack ? ('\n' + err.stack) : ''))
if (!client) return

if (typeof delayTime === 'undefined') delayTime = random.randomInt({ min: 1, max: 10 * msecs.minute })
Expand Down
2 changes: 1 addition & 1 deletion js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ class PaymentsTab extends ImmutableComponent {
<span id='fundsAmount'>
{this.btcToCurrencyString(this.props.ledgerData.get('balance'))}
<a href='https://brave.com/Payments_FAQ.html' target='_blank'>
<span className='fa fa-question-circle fundsFAQ'></span>
<span className='fa fa-question-circle fundsFAQ' />
</a>
</span>
{this.walletButton}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
"keytar": "^3.0.0",
"l20n": "^3.5.1",
"ledger-balance": "^0.8.46",
"ledger-client": "^0.8.50",
"ledger-publisher": "^0.8.47",
"ledger-client": "^0.8.52",
"ledger-publisher": "^0.8.52",
"lru_cache": "^1.0.0",
"random-lib": "2.1.0",
"qr-image": "^3.1.0",
Expand Down