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

Reset old reconcileStamp when re-enabling Payments #4314

Merged
merged 1 commit into from
Sep 27, 2016

Conversation

ayumi
Copy link
Contributor

@ayumi ayumi commented Sep 27, 2016

Fix #4058

Auditors: @mrose17

Test Plan:

  1. Open Brave
  2. Enable Payments then disable
  3. Close Brave
  4. Edit {userData}/ledger-state.json reconcileStamp to be way in the past (change 14.. to 13..)
  5. Open Brave
  6. Enable Payments
  7. Note that contribution date is today + 30 days, rather than way in the past

Copy link
Member

@mrose17 mrose17 left a comment

Choose a reason for hiding this comment

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

just "a few notes" (-;

if (reason === 'changeSettingPaymentsEnabled') {
let timeUntilReconcile = client.timeUntilReconcile()
if (typeof timeUntilReconcile === 'number' && timeUntilReconcile < 0) {
let futureReconcileStamp = underscore.now() + 30 * msecs.day
Copy link
Member

Choose a reason for hiding this comment

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

it is better to call setTimeUntilReconcile with a null timestamp and let the ledger-client package figure out the next time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea

let timeUntilReconcile = client.timeUntilReconcile()
if (typeof timeUntilReconcile === 'number' && timeUntilReconcile < 0) {
let futureReconcileStamp = underscore.now() + 30 * msecs.day
client.setTimeUntilReconcile(futureReconcileStamp, callback)
Copy link
Member

Choose a reason for hiding this comment

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

you shouldn't use callback here, since that's used for client.sync ... look at how the call to setBraveryProperties does it!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, i've updated it

if (action.key === settings.PAYMENTS_CONTRIBUTION_AMOUNT) return setPaymentInfo(action.value)
switch (action.key) {
case settings.PAYMENTS_ENABLED:
return initialize(action.value, 'changeSettingPaymentsEnabled')
Copy link
Member

Choose a reason for hiding this comment

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

probably better to get rid of return and add a break line -- that would be consistent with everything else in the function.

case settings.PAYMENTS_CONTRIBUTION_AMOUNT:
setPaymentInfo(action.value)
break
default:
Copy link
Member

Choose a reason for hiding this comment

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

thank you for adding the default case!

try {
client = ledgerClient(state.personaId,
underscore.extend(state.options, { roundtrip: roundtrip }, clientOptions), state)
client = ledgerClient(
Copy link
Member

Choose a reason for hiding this comment

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

why did the indentation change?

i agree that line 446 is indented too much, that must have been a slip of the finger. i thought it would be:

      client = ledgerClient(state.personaId,
                            underscore.extend(state.options, { roundtrip: roundtrip }, clientOptions), state)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's clearest to indent the 3 parameters equally

Copy link
Member

Choose a reason for hiding this comment

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

except that this is the only example of that style of indentation in the file...

perhaps we can compromise by putting the first parameter right after the "(", and the ")" right after the final parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that sounds fair

Fix #4058

Auditors: @mrose17

Test Plan:
1. Open Brave
2. Enable Payments then disable
2. Close Brave
3. Edit {userData}/ledger-state.json `reconcileStamp` to be way in the past (change 14.. to 13..)
4. Open Brave
5. Enable Payments
6. Note that contribution date is today + 30 days, rather than way in the past
@ayumi ayumi force-pushed the fix/ledger-reset-old-reconcileStamp branch from 43c4d5d to 8f3d16f Compare September 27, 2016 03:12
@bbondy
Copy link
Member

bbondy commented Sep 27, 2016

mrose said it could be merged now, thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants