From 8b04c1c41aaf9cfe162822bf8b3d680f0eb52ede Mon Sep 17 00:00:00 2001 From: zenparsing Date: Wed, 25 May 2022 16:59:30 -0400 Subject: [PATCH] Don't update rewards button until publisher status is known --- .../brave_actions/brave_rewards_action_view.cc | 6 +++++- browser/ui/webui/brave_rewards/rewards_panel_ui.cc | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/browser/ui/views/brave_actions/brave_rewards_action_view.cc b/browser/ui/views/brave_actions/brave_rewards_action_view.cc index e9e2d7016dd0..9a375e2fc7cb 100644 --- a/browser/ui/views/brave_actions/brave_rewards_action_view.cc +++ b/browser/ui/views/brave_actions/brave_rewards_action_view.cc @@ -249,12 +249,14 @@ void BraveRewardsActionView::OnPublisherUpdated( // TODO(zenparsing): Consider an LRUCache for this initialization. publisher_registered_ = {publisher_id, false}; + bool status_pending = false; if (!publisher_id.empty()) { if (auto* rewards_service = GetRewardsService()) { // TODO(zenparsing): When rewards is enabled, should we automatically // check this again? Unfortunately we don't have a way to listen for // Rewards being enabled. Perhaps initialized will work? if (rewards_service->IsRewardsEnabled()) { + status_pending = true; rewards_service->IsPublisherRegistered( publisher_id, base::BindOnce( @@ -264,7 +266,9 @@ void BraveRewardsActionView::OnPublisherUpdated( } } - Update(); + if (!status_pending) { + Update(); + } } void BraveRewardsActionView::OnRewardsPanelRequested(Browser* browser) { diff --git a/browser/ui/webui/brave_rewards/rewards_panel_ui.cc b/browser/ui/webui/brave_rewards/rewards_panel_ui.cc index 161ab529a9c0..4529caa71775 100644 --- a/browser/ui/webui/brave_rewards/rewards_panel_ui.cc +++ b/browser/ui/webui/brave_rewards/rewards_panel_ui.cc @@ -33,6 +33,18 @@ namespace { /* +Functional issues: + +- The button was unresponsive for a while during testing for an unkown reason, + perhaps because the front-end was not calling "showUI". We need to know why + that happened. +- When we press "Refresh" to update a publisher status, the badge is not updated + as expected. +- Switching between verified publisher tabs should not result in a visible flash + of the verified checkmark. + +Other issues: + - Tests for new code. - We are no longer showing the button while the panel is open, due to anchoring difficulties. Is that OK? @@ -52,6 +64,7 @@ using brave_rewards::RewardsPanelServiceFactory; using brave_rewards::RewardsServiceFactory; using brave_rewards::RewardsTabHelper; +// TODO(zenparsing): Alphabetize this list. static constexpr webui::LocalizedString kStrings[] = { {"summary", IDS_REWARDS_PANEL_SUMMARY}, {"tip", IDS_REWARDS_PANEL_TIP},