Skip to content

Commit

Permalink
Merge pull request #890 from brave/contribution-retries
Browse files Browse the repository at this point in the history
Adds retries into contribution flow for rewards
  • Loading branch information
NejcZdovc committed Nov 13, 2018
1 parent 594b688 commit 0743544
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ deps = {
"vendor/python-patch": "https://github.com/svn2github/python-patch@a336a458016ced89aba90dfc3f4c8222ae3b1403",
"vendor/omaha": "https://github.com/brave/omaha.git@dc2582d63a5b92dd39bf7bfd07612e501e133143",
"vendor/sparkle": "https://github.com/brave/Sparkle.git@c0759cce415d7c0feae45005c8a013b1898711f0",
"vendor/bat-native-ledger": "https://github.com/brave-intl/bat-native-ledger@5d514c31c1242b7faa0cf4a7e7f2a5ee9303349f",
"vendor/bat-native-ledger": "https://github.com/brave-intl/bat-native-ledger@9045b873c75165ea569151d34c2c797c07d11257",
"vendor/bat-native-rapidjson": "https://github.com/brave-intl/bat-native-rapidjson.git@86aafe2ef89835ae71c9ed7c2527e3bb3000930e",
"vendor/bip39wally-core-native": "https://github.com/brave-intl/bip39wally-core-native.git@9b119931c702d55be994117eb505d56310720b1d",
"vendor/bat-native-anonize": "https://github.com/brave-intl/bat-native-anonize.git@adeff3254bb90ccdc9699040d5a4e1cd6b8393b7",
Expand Down
13 changes: 12 additions & 1 deletion components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,19 @@ void RewardsServiceImpl::OnReconcileComplete(ledger::Result result,
const std::string& viewing_id,
ledger::PUBLISHER_CATEGORY category,
const std::string& probi) {

RewardsNotificationService::RewardsNotificationArgs args;
args.push_back(viewing_id);
args.push_back(std::to_string(result));
args.push_back(std::to_string(category));
args.push_back(probi);

notification_service_->AddNotification(
RewardsNotificationService::REWARDS_NOTIFICATION_AUTO_CONTRIBUTE,
args,
"contribution_" + viewing_id);

if (result == ledger::Result::LEDGER_OK) {
// TODO add notification service when implemented
auto now = base::Time::Now();
FetchWalletProperties();
ledger_->OnReconcileCompleteSuccess(viewing_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@
"description": ""
},
"braveContributeTitle": {
"message": "Auto-Contribute",
"message": "Contribute",
"description": ""
},
"contributeNotification": {
"contributeNotificationSuccess": {
"message": "You've contributed $amount$BAT",
"description": "",
"placeholders": {
Expand All @@ -188,5 +188,9 @@
"braveRewardsCreatingText": {
"message": "Creating wallet",
"description": ""
},
"contributeNotificationError": {
"message": "There was a problem processing your contribution.",
"description": ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,20 +185,29 @@ export class Panel extends React.Component<Props, State> {

const notification: RewardsExtension.Notification = notifications[currentNotification]

let type: NotificationType
let type: NotificationType = ''
let text = ''
switch (notification.type) {
case 1:
type = 'contribute'
text = getMessage('contributeNotification')
break
{
if (!notification.args ||
!Array.isArray(notification.args) ||
notification.args.length < 3) {
break
}

if (notification.args[1] === '0') {
text = getMessage('contributeNotificationSuccess')
} else {
text = getMessage('contributeNotificationError')
}
type = 'contribute'
break
}
case 2:
type = 'grant'
text = getMessage('grantNotification')
break
default:
type = ''
break
}

return {
Expand Down

0 comments on commit 0743544

Please sign in to comment.