From e237ffeeaf2b16f877d5e2d54820e70f65118de9 Mon Sep 17 00:00:00 2001 From: zenparsing Date: Tue, 30 Jan 2024 14:20:43 -0500 Subject: [PATCH] Rewards self-custody linking improvements - Fix double-scrollbar issue on connect wallet modal - Allow self-custody wallet providers for IN and JP - Disallow concurrent linkage checks --- .../browser/rewards_service_impl.cc | 18 +++++++----------- .../core/wallet_provider/linkage_checker.cc | 4 +++- .../core/wallet_provider/linkage_checker.h | 1 + .../solana/solana_wallet_provider.cc | 1 + .../components/connect_wallet_modal.style.ts | 1 + .../page/components/connect_wallet_modal.tsx | 8 ++++++++ .../rewards_panel/stories/locale_strings.ts | 2 +- .../newtab/stories/locale_strings.ts | 2 +- components/resources/rewards_strings.grdp | 2 +- 9 files changed, 24 insertions(+), 15 deletions(-) diff --git a/components/brave_rewards/browser/rewards_service_impl.cc b/components/brave_rewards/browser/rewards_service_impl.cc index a6fa13db99ce..9ab3a579574c 100644 --- a/components/brave_rewards/browser/rewards_service_impl.cc +++ b/components/brave_rewards/browser/rewards_service_impl.cc @@ -1292,21 +1292,17 @@ std::vector RewardsServiceImpl::GetExternalWalletProviders() if (IsBitFlyerCountry()) { providers.push_back(internal::constant::kWalletBitflyer); - return providers; - } - - if (GetCountryCode() == "IN") { + } else if (GetCountryCode() == "IN") { providers.push_back(internal::constant::kWalletZebPay); - return providers; - } - - providers.push_back(internal::constant::kWalletUphold); + } else { + providers.push_back(internal::constant::kWalletUphold); #if BUILDFLAG(ENABLE_GEMINI_WALLET) - if (base::FeatureList::IsEnabled(features::kGeminiFeature)) { - providers.push_back(internal::constant::kWalletGemini); - } + if (base::FeatureList::IsEnabled(features::kGeminiFeature)) { + providers.push_back(internal::constant::kWalletGemini); + } #endif + } if (base::FeatureList::IsEnabled( features::kAllowSelfCustodyProvidersFeature)) { diff --git a/components/brave_rewards/core/wallet_provider/linkage_checker.cc b/components/brave_rewards/core/wallet_provider/linkage_checker.cc index c1fd4df066bd..3f1d14bf66f9 100644 --- a/components/brave_rewards/core/wallet_provider/linkage_checker.cc +++ b/components/brave_rewards/core/wallet_provider/linkage_checker.cc @@ -37,9 +37,10 @@ void LinkageChecker::Stop() { } void LinkageChecker::CheckLinkage() { - if (!ShouldPerformCheck()) { + if (check_in_progress_ || !ShouldPerformCheck()) { return; } + check_in_progress_ = true; endpoints::RequestFor(engine()).Send(base::BindOnce( &LinkageChecker::CheckLinkageCallback, weak_factory_.GetWeakPtr())); } @@ -146,6 +147,7 @@ void LinkageChecker::UpdateSelfCustodyAvailableDict( void LinkageChecker::CheckLinkageCallback( endpoints::GetWallet::Result&& result) { + check_in_progress_ = false; if (!result.has_value()) { return; } diff --git a/components/brave_rewards/core/wallet_provider/linkage_checker.h b/components/brave_rewards/core/wallet_provider/linkage_checker.h index f2dc529d2769..c486de9ee888 100644 --- a/components/brave_rewards/core/wallet_provider/linkage_checker.h +++ b/components/brave_rewards/core/wallet_provider/linkage_checker.h @@ -40,6 +40,7 @@ class LinkageChecker : public RewardsEngineHelper { void UpdateSelfCustodyAvailableDict(endpoints::GetWallet::Value& value); void CheckLinkageCallback(endpoints::GetWallet::Result&& result); + bool check_in_progress_ = false; base::RepeatingTimer timer_; base::WeakPtrFactory weak_factory_{this}; }; diff --git a/components/brave_rewards/core/wallet_provider/solana/solana_wallet_provider.cc b/components/brave_rewards/core/wallet_provider/solana/solana_wallet_provider.cc index 1c66a0894f50..91acb5764669 100644 --- a/components/brave_rewards/core/wallet_provider/solana/solana_wallet_provider.cc +++ b/components/brave_rewards/core/wallet_provider/solana/solana_wallet_provider.cc @@ -191,6 +191,7 @@ void SolanaWalletProvider::OnWalletLinked(const std::string& address) { } engine().SetState(state::kExternalWalletType, std::string(WalletType())); + engine().SetState(state::kAutoContributeEnabled, false); client().ExternalWalletConnected(); engine().database()->SaveEventLog( log::kWalletVerified, diff --git a/components/brave_rewards/resources/page/components/connect_wallet_modal.style.ts b/components/brave_rewards/resources/page/components/connect_wallet_modal.style.ts index 1362a877e34e..da93b69ed9b5 100644 --- a/components/brave_rewards/resources/page/components/connect_wallet_modal.style.ts +++ b/components/brave_rewards/resources/page/components/connect_wallet_modal.style.ts @@ -18,6 +18,7 @@ export const root = styled.div.attrs({ left: 0; bottom: 0; right: 0; + overscroll-behavior: contain; font: ${leo.font.default.regular}; background: ${leo.color.container.background}; overflow: auto; diff --git a/components/brave_rewards/resources/page/components/connect_wallet_modal.tsx b/components/brave_rewards/resources/page/components/connect_wallet_modal.tsx index 4671dde97d02..8db96cd1ef41 100644 --- a/components/brave_rewards/resources/page/components/connect_wallet_modal.tsx +++ b/components/brave_rewards/resources/page/components/connect_wallet_modal.tsx @@ -41,6 +41,14 @@ export function ConnectWalletModal (props: Props) { const [selectedProvider, setSelectedProvider] = React.useState(null) + React.useEffect(() => { + // While this overlay is displayed, hide any scrollbars attached to the + // document body, as that can result in two visible scrollbars on some + // platforms. + document.body.style.overflow = 'hidden'; + return () => { document.body.style.overflow = ''; } + }, []); + if (props.providers.length === 0) { return null } diff --git a/components/brave_rewards/resources/rewards_panel/stories/locale_strings.ts b/components/brave_rewards/resources/rewards_panel/stories/locale_strings.ts index 3914cc19b788..96ab2f9cd351 100644 --- a/components/brave_rewards/resources/rewards_panel/stories/locale_strings.ts +++ b/components/brave_rewards/resources/rewards_panel/stories/locale_strings.ts @@ -83,7 +83,7 @@ export const localeStrings = { rewardsConnectAccount: 'Connect account', rewardsNotNow: 'Not now', rewardsSelfCustodyInviteHeader: 'Receive BAT directly to a self-custody crypto address', - rewardsSelfCustodyInviteText: 'We’ve added a new option for paying out monthly BAT rewards. Connect a custodial account, or a self-custody wallet to receive Rewards.', + rewardsSelfCustodyInviteText: 'We’ve added a new way for you to receive your monthly BAT rewards. Connect an account from one of our partners or use the new self-custody option to start earning now.', rewardsVBATNoticeTitle1: 'Action required: Connect a custodial account or your vBAT will be lost', rewardsVBATNoticeText1: 'On $1, we will be discontinuing support for existing virtual BAT balances. Connect a custodial account before this date so we can transfer your earned balance to your custodial account, otherwise your balance will be lost.', rewardsVBATNoticeTitle2: 'You still have time to contribute your vBAT to your favorite creators', diff --git a/components/brave_rewards/resources/shared/components/newtab/stories/locale_strings.ts b/components/brave_rewards/resources/shared/components/newtab/stories/locale_strings.ts index fd1f9f6b9e31..0f64c4576f31 100644 --- a/components/brave_rewards/resources/shared/components/newtab/stories/locale_strings.ts +++ b/components/brave_rewards/resources/shared/components/newtab/stories/locale_strings.ts @@ -34,7 +34,7 @@ export const localeStrings = { rewardsSelectCountryHeader: 'Select your country', rewardsSelectCountryText: 'To continue using Brave Rewards, select your country so we can show you the right options and ads for your region. $1Privacy Policy$2', rewardsSelfCustodyInviteHeader: 'Receive BAT directly to a self-custody crypto address', - rewardsSelfCustodyInviteText: 'We’ve added a new option for paying out monthly BAT rewards. Connect a custodial account, or a self-custody wallet to receive Rewards.', + rewardsSelfCustodyInviteText: 'We’ve added a new way for you to receive your monthly BAT rewards. Connect an account from one of our partners or use the new self-custody option to start earning now.', rewardsSettings: 'Rewards settings', rewardsStartUsingRewards: 'Start using Rewards', rewardsTokenGrantTitle: 'A token grant is available!', diff --git a/components/resources/rewards_strings.grdp b/components/resources/rewards_strings.grdp index 61aaa7fdc5c6..87f69c60cb7a 100644 --- a/components/resources/rewards_strings.grdp +++ b/components/resources/rewards_strings.grdp @@ -431,7 +431,7 @@ Receive BAT directly to a self-custody crypto address - We’ve added a new option for paying out monthly BAT rewards. Connect a custodial account, or a self-custody wallet to receive Rewards. + We’ve added a new way for you to receive your monthly BAT rewards. Connect an account from one of our partners or use the new self-custody option to start earning now.