-
Notifications
You must be signed in to change notification settings - Fork 967
Add support for payout status #14063
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
Conversation
bd5cff4
to
f6c926f
Compare
A Storybook has been deployed to preview UI for the latest push |
f6c926f
to
6df470f
Compare
A Storybook has been deployed to preview UI for the latest push |
6df470f
to
a4da516
Compare
A Storybook has been deployed to preview UI for the latest push |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great - mostly just need to look at the any
things.
return type::Result::LEDGER_ERROR; | ||
} | ||
|
||
for (const auto [key, value] : *payout_status_dict) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this copying key
and value
? Is that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it is copying them due to this (new I think?) error in clang:
../../brave/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/api/get_parameters/get_parameters.cc(139,20): error: loop variable '[key, value]' binds to a temporary value produced by a range of type 'const base::Value::Dict' [-Werror,-Wrange-loop-bind-reference]
for (const auto& [key, value] : *payout_status_dict) {
^
../../brave/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/api/get_parameters/get_parameters.cc(139,8): note: use non-reference type 'base::detail::const_dict_iterator::reference' (aka 'pair<const basic_string<char, char_traits<char>, allocator<char>> &, const base::Value &>')
for (const auto& [key, value] : *payout_status_dict) {
^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
I'll use an iterator instead to avoid the copy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, the dict iterator constructs a pair when dereferenced, whose lifetime gets extended by the destructured binding, and we have a compiler setting on to complain about that.
Does for (const auto& pair : *payout_status_dict)
work?
Or maybe it needs to be for (const auto pair : *payout_status_dict)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also curious if for (const auto&& [key, value] : *payout_status_dict)
works :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that does work, perfect!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, that's super weird. That's because base::detail::const_dict_iterator
is a proxy iterator, and Clang warns you that you're extending the lifetime of a std::pair<const std::string&, const base::Value&>
temporary. Not sure why it doesn't complain about const auto&&
, as you're still extending the lifetime... let's remove this const
, though, since it doesn't convey too much semantic meaning here. 🙂
Also, you can use emplace<>()
:
for (auto&& [key, value] : *payout_status_dict) {
if (value.is_string()) {
parameters->payout_status.emplace(key, value.GetString());
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I always forget about emplace
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the &&
- it's a little cryptic, but I suppose it means that we're extending lifetimes explicitly instead of implicitly, which is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang complains about lifetime extension, so it should emit the same warning regardless of whether you're extending the lifetime via a const
lvalue reference, or an rvalue reference. As far as extending lifetime via &&
, this is more like implicit, since auto&&
doesn't necessarily have to be an rvalue reference, it depends on type deduction (although in this specific case, it is). const auto&
, however, is an lvalue reference-to-const (and not a universal/forwarding reference), hence it's more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
components/brave_rewards/resources/shared/lib/provider_payout_status.ts
Outdated
Show resolved
Hide resolved
components/brave_rewards/resources/shared/lib/provider_payout_status.ts
Outdated
Show resolved
Hide resolved
42cdbb1
to
1bcb3e3
Compare
A Storybook has been deployed to preview UI for the latest push |
1bcb3e3
to
5f5c6f5
Compare
5f5c6f5
to
f7809e8
Compare
vendor/bat-native-ledger/src/bat/ledger/internal/state/state.cc
Outdated
Show resolved
Hide resolved
vendor/bat-native-ledger/src/bat/ledger/internal/state/state.cc
Outdated
Show resolved
Hide resolved
f7809e8
to
b52a882
Compare
components/brave_rewards/resources/shared/lib/provider_payout_status.ts
Outdated
Show resolved
Hide resolved
components/brave_rewards/resources/shared/lib/provider_payout_status.ts
Outdated
Show resolved
Hide resolved
@@ -126,7 +128,7 @@ export function PaymentStatusView (props: Props) { | |||
return null | |||
} | |||
|
|||
if (props.earningsReceived) { | |||
if (props.earningsReceived && props.providerPayoutStatus === 'complete') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we'll still show the processing messaging if the status is "processing", even if props.earningsReceived
is true (meaning that the user has accepted the grant). Could that mean that we still show "processing" even after the user claims the grant?
Also, we still use the 3 day window for determining whether to show this messaging at all. Do we still want that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed up the processing issue, good catch.
Regarding the 3-day window, I did intentionally leave that as-is but maybe that wasn't a good idea. @Miyayes do you have any thoughts on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conclusion:
- Remove 3-day window and just display banner based on status from
/parameters
endpoint - Only exception is for
props.earningsReceived
, whereby if it is true, no banner will show (regardless of what is received from /parameters) until the following month
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spoke with @Miyayes privately and we decided to remove the 3-day window and just rely on the endpoint.
A Storybook has been deployed to preview UI for the latest push |
b52a882
to
95bd02a
Compare
A Storybook has been deployed to preview UI for the latest push |
95bd02a
to
3262beb
Compare
A Storybook has been deployed to preview UI for the latest push |
3262beb
to
f983339
Compare
f983339
to
a4cf4c4
Compare
A Storybook has been deployed to preview UI for the latest push |
Windows-based CI runs failed in S3 upload step; other than that, all CI platforms passed. |
Resolves brave/brave-browser#23429
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
Testing is similar to brave/brave-browser#18602 with the additional caveat that payout status is now controlled via a server endpoint which returns one of the following values for a wallet provider or unverified account:
off
(no payment message will be shown at all)processing
(blue "Rewards are on the way" banner is shown)complete
(green "Your Rewards have arrived" banner is shown)Scenario 1: Payment pending messaging
Scenario 1: Payment processing messaging
Scenario 3: Payment arrived messaging