Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes false insufficient funds notification (uplift to 0.62.x) #2116

Merged
merged 1 commit into from
Mar 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions components/brave_rewards/browser/rewards_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ void RewardsService::RegisterProfilePrefs(PrefRegistrySimple* registry) {
base::TimeDelta::FromDays(7));
registry->RegisterTimeDeltaPref(prefs::kRewardsBackupNotificationInterval,
base::TimeDelta::FromDays(7));
registry->RegisterTimeDeltaPref(prefs::kRewardsNotificationStartupDelay,
base::TimeDelta::FromSeconds(30));
registry->RegisterBooleanPref(prefs::kRewardsBackupSucceeded, false);
registry->RegisterBooleanPref(prefs::kRewardsUserHasFunded, false);
registry->RegisterTimePref(prefs::kRewardsAddFundsNotification, base::Time());
Expand Down
9 changes: 6 additions & 3 deletions components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2113,15 +2113,18 @@ RewardsNotificationService* RewardsServiceImpl::GetNotificationService() const {
void RewardsServiceImpl::StartNotificationTimers(bool main_enabled) {
if (!main_enabled) return;

// Startup timer, begins after 3-second delay.
// Startup timer, begins after 30-second delay.
PrefService* pref_service = profile_->GetPrefs();
notification_startup_timer_ = std::make_unique<base::OneShotTimer>();
notification_startup_timer_->Start(
FROM_HERE, base::TimeDelta::FromSeconds(3), this,
FROM_HERE,
pref_service->GetTimeDelta(
prefs::kRewardsNotificationStartupDelay),
this,
&RewardsServiceImpl::OnNotificationTimerFired);
DCHECK(notification_startup_timer_->IsRunning());

// Periodic timer, runs once per day by default.
PrefService* pref_service = profile_->GetPrefs();
base::TimeDelta periodic_timer_interval =
pref_service->GetTimeDelta(prefs::kRewardsNotificationTimerInterval);
notification_periodic_timer_ = std::make_unique<base::RepeatingTimer>();
Expand Down
1 change: 1 addition & 0 deletions components/brave_rewards/common/pref_names.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const char kRewardsBackupNotificationInterval[] =
const char kRewardsBackupSucceeded[] = "brave.rewards.backup_succeeded";
const char kRewardsUserHasFunded[] = "brave.rewards.user_has_funded";
const char kRewardsAddFundsNotification[] = "brave.rewards.add_funds_notification";
const char kRewardsNotificationStartupDelay[] = "brave.rewards.notification_startup_delay";

} // namespace prefs
} // namespace brave_rewards
1 change: 1 addition & 0 deletions components/brave_rewards/common/pref_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extern const char kRewardsBackupNotificationInterval[];
extern const char kRewardsBackupSucceeded[];
extern const char kRewardsUserHasFunded[];
extern const char kRewardsAddFundsNotification[];
extern const char kRewardsNotificationStartupDelay[];

} // namespace prefs
} // namespace brave_rewards
Expand Down