Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Adds wallet properties implementation #293

Closed
wants to merge 2 commits into from

Conversation

NejcZdovc
Copy link
Contributor

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.
  • Request a security/privacy review as needed.

Test Plan:

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions

@@ -238,6 +238,10 @@ void PaymentsServiceImpl::OnWalletCreated(ledger::Result result) {
TriggerOnWalletCreated(result);
}

void PaymentsServiceImpl::OnWalletProperties(ledger::WalletProperties result) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't want to expose ledger outside of the payments service. What exactly is in wallet properties?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this are the fields https://github.com/brave-intl/bat-native-ledger/pull/26/files#diff-2779bd349aa484b3cafcf4c1a138efd5R22. We use them all in UI, like balance, grants, range and choices for monthly contribution

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we have individual methods for the balance and we should add them for anything else you need

Copy link
Collaborator

Choose a reason for hiding this comment

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

but we should never directly expose anything in ledger. For Grants you might want to do something like ContentSite to expose whatever fields we need in the UI

Copy link
Collaborator

Choose a reason for hiding this comment

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

basically we should only expose the things in payment service that we actually use in the brave rewards ui and leave all the internal details inside of ledger

Copy link
Collaborator

Choose a reason for hiding this comment

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

if any kind of translation needs to be made to put it in the format we want for the user, that translation should happen in the payment service

@NejcZdovc NejcZdovc force-pushed the walletProperties branch 5 times, most recently from a2b26a5 to 93954ee Compare July 28, 2018 06:51
}
}
}
web_ui()->CallJavascriptFunctionUnsafe("brave_rewards.walletProperties");
Copy link
Collaborator

Choose a reason for hiding this comment

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

wouldn't this be a generic method to update the state with the new webui props?

Copy link
Contributor Author

@NejcZdovc NejcZdovc Jul 29, 2018

Choose a reason for hiding this comment

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

yeah I still need to check if generic could be applied here (because I need to check all cases). Problem is that we could be doing some specific actions after we update state and we would need to know which action was triggered to for example reset some timers or something like this

Copy link
Collaborator

Choose a reason for hiding this comment

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

we can also keep the balance update timers in c++ and just update the props

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we talked about this with @bbondy and we decided to have all timers in app and only do calls to library when needed

Copy link
Collaborator

Choose a reason for hiding this comment

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

well, I'm not even a big fan of the fact that the balance update runs continuously when the payments ui is active and we definitely don't want it running all the time. I think it probably makes sense to put that inside the webcontents observer though and not JS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

balance is running only when you are on rewards page (chrome://rewards). We are already quite smart about it, so for example when you claim grant we call balance etc, so maybe we can have this conversation again and increase timer from a minute to something higher

case types.GET_WALLET_PROPERTIES:
chrome.send('getWalletProperties', [])
break
case types.ON_WALLET_PROPERTIES:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, so you're treating the response as an action to update the store? That seems like a reasonable route to go as well. I was thinking thinking something more like writing webui properties as store.propertyname and using a generic mechanism to write those to the actual store for the page, but either way works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so to basically have 1:1 mapping with redux store? this is how I did so far https://github.com/brave/brave-core/pull/293/files#diff-aa3505dbf36b5d03d8ba0751e0c99904R124 which I think it's quite the same as you were thinking.

@NejcZdovc NejcZdovc force-pushed the walletProperties branch 2 times, most recently from ad6e622 to 1514e65 Compare August 1, 2018 04:05
@NejcZdovc
Copy link
Contributor Author

closing in favour of #241

@NejcZdovc NejcZdovc closed this Aug 1, 2018
@NejcZdovc NejcZdovc deleted the walletProperties branch September 27, 2018 13:41
fmarier pushed a commit that referenced this pull request Oct 29, 2019
@NejcZdovc NejcZdovc added this to the Closed milestone Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants