Skip to content

Commit

Permalink
Merge pull request #2337 from brave/claimed-grant-date
Browse files Browse the repository at this point in the history
Removes date from ads grants in the wallet
  • Loading branch information
NejcZdovc committed May 3, 2019
1 parent bb6cc3d commit ca913fc
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 48 deletions.
1 change: 1 addition & 0 deletions browser/ui/webui/brave_donate_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,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
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,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 @@ -530,6 +531,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
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,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
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@
"expiryTime": {
"type": "integer",
"description": "when grant expires, timestamp in seconds"
},
"type": {
"type": "string",
"description": "grant type, ugp or ads"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,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
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,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 @@ -1395,6 +1396,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
Original file line number Diff line number Diff line change
Expand Up @@ -356,5 +356,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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const getUIMessages = (): Record<string, string> => {
'unVerifiedText',
'unVerifiedTextMore',
'verifiedPublisher',
'adsEarnings',
'welcomeButtonTextOne',
'welcomeButtonTextTwo',
'welcomeDescOne',
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,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
51 changes: 16 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
"@types/react-redux": "6.0.4",
"@types/redux-logger": "^3.0.7",
"awesome-typescript-loader": "^5.2.1",
"brave-ui": "github:brave/brave-ui#b94af34d0e556795b912499ab80ba2e08d689b8a",
"brave-ui": "github:brave/brave-ui#45a826dab14438b564fdf37e3b2d81b0e7027c56",
"css-loader": "^2.1.1",
"csstype": "^2.5.5",
"deep-freeze-node": "^1.1.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ ledger::WalletInfo BatClient::WalletPropertiesToWalletInfo(
grant.altcurrency = properties.grants_[i].altcurrency;
grant.probi = properties.grants_[i].probi;
grant.expiryTime = properties.grants_[i].expiryTime;
grant.type = properties.grants_[i].type;

info.grants_.push_back(grant);
}
Expand Down
11 changes: 11 additions & 0 deletions vendor/bat-native-ledger/src/bat/ledger/internal/bat_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,10 @@ bool WALLET_PROPERTIES_ST::loadFromJson(const std::string & json) {
grant.expiryTime = obj["expiryTime"].GetUint64();
}

if (obj.HasMember("type")) {
grant.type = obj["type"].GetString();
}

grants_.push_back(grant);
}
} else {
Expand Down Expand Up @@ -1140,6 +1144,9 @@ void saveToJson(JsonWriter* writer, const GRANT& data) {
writer->String("promotionId");
writer->String(data.promotionId.c_str());

writer->String("type");
writer->String(data.type.c_str());

writer->EndObject();
}

Expand Down Expand Up @@ -2050,6 +2057,10 @@ bool getJSONRecoverWallet(const std::string& json,
grant.expiryTime = obj["expiryTime"].GetUint64();
}

if (obj.HasMember("type")) {
grant.type = obj["type"].GetString();
}

grants->push_back(grant);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ void LedgerImpl::OnRecoverWallet(
tempGrant.altcurrency = grants[i].altcurrency;
tempGrant.probi = grants[i].probi;
tempGrant.expiryTime = grants[i].expiryTime;
tempGrant.type = grants[i].type;

ledgerGrants.push_back(tempGrant);
}
Expand Down

0 comments on commit ca913fc

Please sign in to comment.