Skip to content

Commit 6c19846

Browse files
authored
Merge pull request #166 from brave-intl/clear-reports-lib
Rewards summary should now be cleared when wallet is restored
2 parents f15bad7 + 7cccafa commit 6c19846

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/bat_publishers.cc

+8
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,14 @@ bool BatPublishers::isEligibleForContribution(const ledger::PublisherInfo& info)
722722

723723
}
724724

725+
void BatPublishers::clearAllBalanceReports() {
726+
if (state_->monthly_balances_.empty()) {
727+
return;
728+
}
729+
state_->monthly_balances_.clear();
730+
saveState();
731+
}
732+
725733
void BatPublishers::setBalanceReport(ledger::PUBLISHER_MONTH month,
726734
int year,
727735
const ledger::BalanceReportInfo& report_info) {

src/bat_publishers.h

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ class BatPublishers : public ledger::LedgerCallbackHandler {
126126
bool min_duration,
127127
const uint64_t& currentReconcileStamp);
128128

129+
void clearAllBalanceReports();
130+
129131
private:
130132

131133
void onPublisherActivitySave(uint64_t windowId,

src/ledger_impl.cc

+3
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,9 @@ void LedgerImpl::OnRecoverWallet(ledger::Result result, double balance, const st
603603

604604
ledgerGrants.push_back(tempGrant);
605605
}
606+
if (result == ledger::Result::LEDGER_OK) {
607+
bat_publishers_->clearAllBalanceReports();
608+
}
606609

607610
ledger_client_->OnRecoverWallet(result ? ledger::Result::LEDGER_ERROR :
608611
ledger::Result::LEDGER_OK,

0 commit comments

Comments
 (0)