Skip to content

Commit

Permalink
Merge pull request #1823 from brave/activity-publisher
Browse files Browse the repository at this point in the history
Fixes publisher info getting lost on publishers not in activity table
  • Loading branch information
NejcZdovc authored Mar 4, 2019
2 parents 9265610 + 081766e commit c342c2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1039,19 +1039,23 @@ void RewardsServiceImpl::LoadActivityInfo(
0, 2, filter, publisher_info_backend_.get()),
base::Bind(&RewardsServiceImpl::OnActivityInfoLoaded,
AsWeakPtr(),
callback));
callback,
filter.id));
}

void RewardsServiceImpl::OnActivityInfoLoaded(
ledger::PublisherInfoCallback callback,
const std::string& publisher_key,
const ledger::PublisherInfoList list) {
if (!Connected()) {
return;
}

// activity info not found
if (list.size() == 0) {
callback(ledger::Result::NOT_FOUND,
std::unique_ptr<ledger::PublisherInfo>());
// we need to try to get at least publisher info in this case
// this way we preserve publisher info
LoadPublisherInfo(publisher_key, callback);
return;
} else if (list.size() > 1) {
callback(ledger::Result::TOO_MANY_RESULTS,
Expand Down
3 changes: 2 additions & 1 deletion components/brave_rewards/browser/rewards_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ class RewardsServiceImpl : public RewardsService,
std::unique_ptr<ledger::PublisherInfo> info,
bool success);
void OnActivityInfoLoaded(ledger::PublisherInfoCallback callback,
const ledger::PublisherInfoList list);
const std::string& publisher_key,
const ledger::PublisherInfoList list);
void OnMediaPublisherInfoSaved(bool success);
void OnPublisherInfoLoaded(ledger::PublisherInfoCallback callback,
std::unique_ptr<ledger::PublisherInfo> info);
Expand Down

0 comments on commit c342c2c

Please sign in to comment.