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

Ledger notifications refactor and add new BTC=>BAT notification #11265

Merged
merged 1 commit into from
Oct 4, 2017
Merged

Ledger notifications refactor and add new BTC=>BAT notification #11265

merged 1 commit into from
Oct 4, 2017

Conversation

bsclifton
Copy link
Member

@bsclifton bsclifton commented Oct 3, 2017

screen shot 2017-10-03 at 4 48 39 pm

Fixes #11021

Presents this one-time "Converted BTC to BAT" alert:

  • if payments are enabled
  • user has a positive balance
  • this is an existing profile (new profiles will have firstRunTimestamp matching btcToBatTimestamp)
  • notification has not already been shown yet

Includes a "learn more" link pointing to:
https://brave.com/faq-payments/#brave-payments

Has a possible security risk- the deep link allows URL hash to modify state (limited to boolean state variables on about:preferences)

Auditors: @NejcZdovc, @diracdeltas

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.

Automated Test Plan:

npm run unittest -- --grep="ledger api unit tests"
npm run unittest -- --grep="ledgerReducer unit tests"
npm run unittest -- --grep="Preferences component"

Reviewer Checklist:

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

Merge Checklist:

  • Merge to master
  • rebase to 0.20.x (taking care to make sure setting names match)
  • cherry-pick the 0.20.x rebase to 0.19.x
  • list commit hashes here

* Parses a query string like:
* about:preferences#payments?ledgerBackupOverlayVisible
* and returns the part:
* `about:preferences#payments`
Copy link
Member

@diracdeltas diracdeltas Oct 4, 2017

Choose a reason for hiding this comment

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

This comment doesn't seem right. this function would return 'payments' not 'about:preferences#payments'.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch; fixed 😄

@codecov-io
Copy link

codecov-io commented Oct 4, 2017

Codecov Report

Merging #11265 into master will increase coverage by 0.69%.
The diff coverage is 35.13%.

@@            Coverage Diff             @@
##           master   #11265      +/-   ##
==========================================
+ Coverage   51.43%   52.12%   +0.69%     
==========================================
  Files         263      263              
  Lines       24541    24617      +76     
  Branches     3928     3940      +12     
==========================================
+ Hits        12623    12832     +209     
+ Misses      11918    11785     -133
Flag Coverage Δ
#unittest 52.12% <35.13%> (+0.69%) ⬆️
Impacted Files Coverage Δ
app/sessionStore.js 75.56% <ø> (ø) ⬆️
js/constants/appConstants.js 100% <ø> (ø) ⬆️
app/locale.js 35.23% <ø> (ø) ⬆️
app/browser/reducers/ledgerReducer.js 45.52% <100%> (+0.44%) ⬆️
js/actions/appActions.js 14.73% <100%> (+1.79%) ⬆️
app/browser/api/ledger.js 21.07% <27.87%> (+8.84%) ⬆️
js/about/preferences.js 45.85% <93.75%> (+3.53%) ⬆️
... and 4 more

if (getSetting(settings.PAYMENTS_ENABLED)) {
notifications.showEnabledNotifications(state)
} else {
notifications.showDisabledNotifications(state)
Copy link
Member

Choose a reason for hiding this comment

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

before we showed this notification only when !getSetting(settings.PAYMENTS_NOTIFICATIONS) is that change intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

logic shouldn't have changed at all (just moved). If PAYMENT_NOTIFICATIONS is set, none of the notifications should be shown

Copy link
Member

@bbondy bbondy Oct 4, 2017

Choose a reason for hiding this comment

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

I guess I'm thinking about getSetting(settings.PAYMENTS_NOTIFICATIONS) is false and getSetting(settings.PAYMENTS_ENABLED) is false, before it would show.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great catch- I rolled back to the original behavior (so that there is no change from previous code)

return
}

appActions.hideNotification(message)
Copy link
Member

Choose a reason for hiding this comment

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

maybe the above default: should be just break so this always runs?

Copy link
Member Author

Choose a reason for hiding this comment

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

I considered that... but since other messages may be coming through (since this fires on ipc.on(messages.NOTIFICATION_RESPONSE) I didn't want to change the behavior

Copy link
Contributor

@NejcZdovc NejcZdovc left a comment

Choose a reason for hiding this comment

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

code looks good to me, I don't have positive balance, so can't test it fully. I agree with you that it would be nice to move notification into separate file

Fixes #11021

Presents this one-time "Converted BTC to BAT" alert:
 - if payments are enabled
 - user has a positive balance
 - this is an existing profile (new profiles will have firstRunTimestamp matching btcToBatTimestamp)
 - notification has not already been shown yet

Includes a "learn more" link pointing to:
https://brave.com/faq-payments/#brave-payments

Has a possible security risk- the deep link allows URL hash to modify state (limited to boolean state variables on about:preferences)

Auditors: @NejcZdovc, @diracdeltas

Test Plan:
`npm run unittest -- --grep="ledger api unit tests"`
`npm run unittest -- --grep="ledgerReducer unit tests"`
`npm run unittest -- --grep="Preferences component"`
@bsclifton bsclifton merged commit 9285507 into brave:master Oct 4, 2017
@bsclifton bsclifton deleted the bat-notification branch October 4, 2017 17:01
@bradleyrichter
Copy link
Contributor

@bsclifton This alert bar location looks wrong. The screen shot above shows the per-tab location and this should be at the app level.

@luixxiul
Copy link
Contributor

luixxiul commented Oct 4, 2017

tracked here: #11256

@luixxiul
Copy link
Contributor

luixxiul commented Oct 4, 2017

also: #8934

bsclifton added a commit that referenced this pull request Oct 4, 2017
Ledger notifications refactor and add new BTC=>BAT notification
bsclifton added a commit that referenced this pull request Oct 4, 2017
Ledger notifications refactor and add new BTC=>BAT notification
@bsclifton
Copy link
Member Author

master 9285507
0.20.x 8f2fc5c
0.19.x e84899a

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