Skip to content

Commit

Permalink
Merge pull request #699 from jasonrsadler/pub_media_panel_core
Browse files Browse the repository at this point in the history
Youtube media publishers now appear properly in Rewards panel
  • Loading branch information
NejcZdovc committed Oct 29, 2018
1 parent 3a73967 commit 2dcd0e7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 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@5c633e867efafb9013c57ca830212d1ff6ea5076",
"vendor/sparkle": "https://github.com/brave/Sparkle.git@c0759cce415d7c0feae45005c8a013b1898711f0",
"vendor/bat-native-ledger": "https://github.com/brave-intl/bat-native-ledger@d50120871086cc1c35625a73de2088b5fd454b8f",
"vendor/bat-native-ledger": "https://github.com/brave-intl/bat-native-ledger@e5e7586ed94a36f2f8aab285aacfe040cc224b1c",
"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
6 changes: 5 additions & 1 deletion components/brave_rewards/browser/publisher_info_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ PublisherInfoDatabase::GetMediaPublisherInfo(const std::string& media_key) {
return info;

sql::Statement info_sql(
db_.GetUniqueStatement("SELECT pi.publisher_id, pi.name, pi.url, pi.favIcon "
db_.GetUniqueStatement("SELECT pi.publisher_id, pi.name, pi.url, pi.favIcon, "
"pi.provider, pi.verified, pi.excluded "
"FROM media_publisher_info as mpi "
"INNER JOIN publisher_info AS pi ON mpi.publisher_id = pi.publisher_id "
"WHERE mpi.media_key=?"));
Expand All @@ -361,6 +362,9 @@ PublisherInfoDatabase::GetMediaPublisherInfo(const std::string& media_key) {
info->name = info_sql.ColumnString(1);
info->url = info_sql.ColumnString(2);
info->favicon_url = info_sql.ColumnString(3);
info->provider = info_sql.ColumnString(4);
info->verified = info_sql.ColumnBool(5);
info->excluded = static_cast<ledger::PUBLISHER_EXCLUDE>(info_sql.ColumnInt(6));
}
return info;
}
Expand Down
2 changes: 1 addition & 1 deletion components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ void RewardsServiceImpl::GetPublisherActivityFromUrl(uint64_t windowId,

ledger::VisitData visitData;
visitData.domain = baseDomain;
visitData.path = parsedUrl.path();
visitData.path = parsedUrl.PathForRequest();
visitData.local_month = GetPublisherMonth(now);
visitData.local_year = GetPublisherYear(now);
visitData.name = baseDomain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ export class Panel extends React.Component<Props, State> {
const converted = utils.convertBalance(balance.toString(), rates)
const notification = this.getNotification()

let faviconUrl
if (publisher && publisher.url) {
faviconUrl = `chrome://favicon/size/48@1x/${publisher.url}`
if (publisher.favicon_url) {
faviconUrl = `chrome://favicon/size/48@1x/${publisher.favicon_url}`
}
}
return (
<WalletWrapper
compact={true}
Expand Down Expand Up @@ -251,7 +258,7 @@ export class Panel extends React.Component<Props, State> {
id={'wallet-panel'}
platform={publisher.provider as Provider}
publisherName={publisher.name}
publisherImg={publisher.favicon_url || `chrome://favicon/size/48@2x/${publisher.url}`}
publisherImg={faviconUrl}
monthlyAmount={10}
isVerified={publisher.verified}
tipsEnabled={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,14 @@ class ContributeBox extends React.Component<Props, State> {

getContributeRows = (list: Rewards.Publisher[]) => {
return list.map((item: Rewards.Publisher) => {
let name = item.name
if (item.provider) {
name = `${name} ${getLocale('on')} ${item.provider}`
}

let faviconUrl = `chrome://favicon/size/48@1x/${item.url}`
if (item.favIcon) {
faviconUrl = `chrome://favicon/size/48@1x/${item.favIcon}`
}

return {
profile: {
name,
name: item.name,
verified: item.verified,
provider: (item.provider ? item.provider : undefined) as Provider,
src: faviconUrl
Expand Down

0 comments on commit 2dcd0e7

Please sign in to comment.