Skip to content

Commit

Permalink
Removes date from ads grants in the wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Apr 26, 2019
1 parent af76b8e commit c3f2ea0
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 84 deletions.
1 change: 1 addition & 0 deletions browser/ui/webui/brave_donate_ui.cc
Expand Up @@ -174,6 +174,7 @@ void RewardsDonateDOMHandler::OnWalletProperties(
auto grant = std::make_unique<base::DictionaryValue>();
grant->SetString("probi", item.probi);
grant->SetInteger("expiryTime", item.expiryTime);
grant->SetString("type", item.type);
grants->Append(std::move(grant));
}
walletInfo->SetList("grants", std::move(grants));
Expand Down
2 changes: 2 additions & 0 deletions browser/ui/webui/brave_rewards_ui.cc
Expand Up @@ -425,6 +425,7 @@ void RewardsDOMHandler::OnGetAutoContributeProps(
auto grant = std::make_unique<base::DictionaryValue>();
grant->SetString("probi", item.probi);
grant->SetInteger("expiryTime", item.expiryTime);
grant->SetString("type", item.type);
grants->Append(std::move(grant));
}
walletInfo->SetList("grants", std::move(grants));
Expand Down Expand Up @@ -545,6 +546,7 @@ void RewardsDOMHandler::OnRecoverWallet(
auto grant = std::make_unique<base::DictionaryValue>();
grant->SetString("probi", item.probi);
grant->SetInteger("expiryTime", item.expiryTime);
grant->SetString("type", item.type);
newGrants->Append(std::move(grant));
}
recover.SetList("grants", std::move(newGrants));
Expand Down
1 change: 1 addition & 0 deletions browser/ui/webui/brave_webui_source.cc
Expand Up @@ -270,6 +270,7 @@ void CustomizeWebUIHTMLSource(const std::string &name,
{ "addFundsQR", IDS_BRAVE_UI_ADD_FUNDS_QR},
{ "addFundsText", IDS_BRAVE_UI_ADD_FUNDS_TEXT},
{ "addFundsTitle", IDS_BRAVE_UI_ADD_FUNDS_TITLE},
{ "adsEarnings", IDS_BRAVE_UI_ADS_EARNINGS },
{ "allowTip", IDS_BRAVE_UI_ALLOW_TIP },
{ "amount", IDS_BRAVE_UI_AMOUNT },
{ "backup", IDS_BRAVE_UI_BACKUP },
Expand Down
4 changes: 4 additions & 0 deletions common/extensions/api/brave_rewards.json
Expand Up @@ -177,6 +177,10 @@
"expiryTime": {
"type": "integer",
"description": "when grant expires, timestamp in seconds"
},
"type": {
"type": "string",
"description": "grant type, ugp or ads"
}
}
}
Expand Down
Expand Up @@ -80,6 +80,7 @@ void ExtensionRewardsServiceObserver::OnWalletProperties(
grant.altcurrency = wallet_properties->grants[i].altcurrency;
grant.probi = wallet_properties->grants[i].probi;
grant.expiry_time = wallet_properties->grants[i].expiryTime;
grant.type = wallet_properties->grants[i].type;
}

std::unique_ptr<base::ListValue> args(
Expand Down
2 changes: 2 additions & 0 deletions components/brave_rewards/browser/rewards_service_impl.cc
Expand Up @@ -804,6 +804,7 @@ void RewardsServiceImpl::OnWalletProperties(
grant.altcurrency = wallet_info->grants_[i].altcurrency;
grant.probi = wallet_info->grants_[i].probi;
grant.expiryTime = wallet_info->grants_[i].expiryTime;
grant.type = wallet_info->grants_[i].type;

wallet_properties->grants.push_back(grant);
}
Expand Down Expand Up @@ -1431,6 +1432,7 @@ void RewardsServiceImpl::TriggerOnRecoverWallet(ledger::Result result,
grant.altcurrency = grants[i].altcurrency;
grant.probi = grants[i].probi;
grant.expiryTime = grants[i].expiryTime;
grant.type = grants[i].type;

newGrants.push_back(grant);
}
Expand Down
Expand Up @@ -408,5 +408,9 @@
"turnOnAds": {
"message": "Turn on Ads",
"description": "Prompt to turn on Ads via notification"
},
"adsEarnings": {
"message": "earned from ads",
"description": "Description text for ad grants in grant details"
}
}
Expand Up @@ -98,6 +98,7 @@ export const getUIMessages = (): Record<string, string> => {
'unVerifiedText',
'unVerifiedTextMore',
'verifiedPublisher',
'adsEarnings',
'welcomeButtonTextOne',
'welcomeButtonTextTwo',
'welcomeDescOne',
Expand Down
Expand Up @@ -39,14 +39,10 @@ export const getGrants = (grants?: RewardsExtension.Grant[]) => {
}

return grants.map((grant: RewardsExtension.Grant) => {
let expireDate = ''
if (grant.type !== 'ads') {
expireDate = new Date(grant.expiryTime * 1000).toLocaleDateString()
}

return {
tokens: convertProbiToFixed(grant.probi),
expireDate
expireDate: new Date(grant.expiryTime * 1000).toLocaleDateString(),
type: grant.type || 'ugp'
}
})
}
Expand Down
Expand Up @@ -156,14 +156,10 @@ class PageWallet extends React.Component<Props, State> {
}

return grants.map((grant: Rewards.Grant) => {
let expireDate = ''
if (grant.type !== 'ads') {
expireDate = new Date(grant.expiryTime * 1000).toLocaleDateString()
}

return {
tokens: utils.convertProbiToFixed(grant.probi),
expireDate
expireDate: new Date(grant.expiryTime * 1000).toLocaleDateString(),
type: grant.type || 'ugp'
}
})
}
Expand Down
1 change: 1 addition & 0 deletions components/resources/brave_components_strings.grd
Expand Up @@ -498,6 +498,7 @@
<message name="IDS_BRAVE_UI_SITE_BANNER_NOTICE_NOTE" desc="">NOTE:</message>
<message name="IDS_BRAVE_UI_SITE_BANNER_NOTICE_TEXT" desc="">This creator has not yet signed up to receive contributions from Brave users. Your browser will keep trying to contribute until they verify, or until 90 days have passed.</message>
<message name="IDS_BRAVE_UI_SITE_UNVERIFIED_TEXT_MORE" desc="">Learn more.</message>
<message name="IDS_BRAVE_UI_ADS_EARNINGS" desc="Description text for ad grants in grant details">earned from ads</message>

<!-- WebUI brave sync resources -->
<!-- WebUI brave sync resources: Shared Content -->
Expand Down

0 comments on commit c3f2ea0

Please sign in to comment.