Skip to content

Commit

Permalink
Merge pull request #194 from ryanml/fix-2340
Browse files Browse the repository at this point in the history
Adds publisherKey to OnExcludedSitesChanged callback
  • Loading branch information
NejcZdovc committed Dec 5, 2018
1 parent 27f4c8b commit d5602b1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/bat/ledger/ledger_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class LEDGER_EXPORT LedgerClient {
virtual void OnPublisherActivity(Result result,
std::unique_ptr<ledger::PublisherInfo>,
uint64_t windowId) = 0;
virtual void OnExcludedSitesChanged() = 0;
virtual void OnExcludedSitesChanged(const std::string& publisher_id) = 0;
virtual void FetchFavIcon(const std::string& url,
const std::string& favicon_key,
FetchIconCallback callback) = 0;
Expand Down
13 changes: 9 additions & 4 deletions src/bat_publishers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,12 @@ void BatPublishers::onSetExcludeInternal(ledger::PUBLISHER_EXCLUDE exclude,
publisher_info->month = ledger::PUBLISHER_MONTH::ANY;
setNumExcludedSitesInternal(exclude);

std::string publisherKey = publisher_info->id;

ledger_->SetPublisherInfo(std::move(publisher_info),
std::bind(&BatPublishers::onSetPublisherInfo, this, _1, _2));

OnExcludedSitesChanged();
OnExcludedSitesChanged(publisherKey);
}

void BatPublishers::onSetPublisherInfo(ledger::Result result,
Expand Down Expand Up @@ -375,10 +377,13 @@ void BatPublishers::onSetPanelExcludeInternal(ledger::PUBLISHER_EXCLUDE exclude,
setNumExcludedSitesInternal(exclude);

ledger::VisitData visit_data;
std::string publisherKey = publisher_info->id;

ledger_->SetPublisherInfo(std::move(publisher_info),
std::bind(&BatPublishers::onPublisherActivity, this, _1, _2,
windowId, visit_data));
OnExcludedSitesChanged();

OnExcludedSitesChanged(publisherKey);
}

void BatPublishers::restorePublishers() {
Expand Down Expand Up @@ -820,8 +825,8 @@ void BatPublishers::onPublisherActivity(ledger::Result result,
}
}

void BatPublishers::OnExcludedSitesChanged() {
ledger_->OnExcludedSitesChanged();
void BatPublishers::OnExcludedSitesChanged(const std::string& publisher_id) {
ledger_->OnExcludedSitesChanged(publisher_id);
}

void BatPublishers::setBalanceReportItem(ledger::PUBLISHER_MONTH month,
Expand Down
2 changes: 1 addition & 1 deletion src/bat_publishers.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class BatPublishers : public ledger::LedgerCallbackHandler {
uint64_t windowId,
const ledger::VisitData& visit_data);

void OnExcludedSitesChanged();
void OnExcludedSitesChanged(const std::string& publisher_id);

void onPublisherBanner(ledger::PublisherBannerCallback callback,
ledger::PublisherBanner banner,
Expand Down
4 changes: 2 additions & 2 deletions src/ledger_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,8 @@ void LedgerImpl::OnPublisherActivity(ledger::Result result,
ledger_client_->OnPublisherActivity(result, std::move(info), windowId);
}

void LedgerImpl::OnExcludedSitesChanged() {
ledger_client_->OnExcludedSitesChanged();
void LedgerImpl::OnExcludedSitesChanged(const std::string& publisher_id) {
ledger_client_->OnExcludedSitesChanged(publisher_id);
}

void LedgerImpl::SetBalanceReportItem(ledger::PUBLISHER_MONTH month,
Expand Down
2 changes: 1 addition & 1 deletion src/ledger_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class LedgerImpl : public ledger::Ledger,
void OnPublisherActivity(ledger::Result result,
std::unique_ptr<ledger::PublisherInfo> info,
uint64_t windowId);
void OnExcludedSitesChanged();
void OnExcludedSitesChanged(const std::string& publisher_id);
void SetBalanceReportItem(ledger::PUBLISHER_MONTH month,
int year,
ledger::ReportType type,
Expand Down

0 comments on commit d5602b1

Please sign in to comment.