Skip to content

Commit

Permalink
Don't update rewards button until publisher status is known
Browse files Browse the repository at this point in the history
  • Loading branch information
zenparsing committed May 26, 2022
1 parent 6b67867 commit 8b04c1c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion browser/ui/views/brave_actions/brave_rewards_action_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -264,7 +266,9 @@ void BraveRewardsActionView::OnPublisherUpdated(
}
}

Update();
if (!status_pending) {
Update();
}
}

void BraveRewardsActionView::OnRewardsPanelRequested(Browser* browser) {
Expand Down
13 changes: 13 additions & 0 deletions browser/ui/webui/brave_rewards/rewards_panel_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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},
Expand Down

0 comments on commit 8b04c1c

Please sign in to comment.