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

Fix Rewards connection modal retry (uplift to 1.62.x) #21509

Merged
merged 1 commit into from
Jan 12, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@
import * as React from 'react'

import { useActions, useRewardsData } from '../lib/redux_hooks'
import { lookupExternalWalletProviderName } from '../../shared/lib/external_wallet'
import { externalWalletProviderFromString, getExternalWalletProviderName } from '../../shared/lib/external_wallet'
import { LocaleContext } from '../../shared/lib/locale_context'
import { ModalRedirect } from '../../ui/components'
import * as mojom from '../../shared/lib/mojom'

export function ProviderRedirectModal () {
const { getString } = React.useContext(LocaleContext)
const actions = useActions()
const { externalWallet, modalRedirect } = useRewardsData((data) => ({
externalWallet: data.externalWallet,
const { modalRedirectProvider, modalRedirect } = useRewardsData((data) => ({
modalRedirectProvider: data.ui.modalRedirectProvider,
modalRedirect: data.ui.modalRedirect
}))

const walletType = externalWallet ? externalWallet.type : ''
const providerName = lookupExternalWalletProviderName(walletType)
const walletType =
externalWalletProviderFromString(modalRedirectProvider) || undefined
const providerName =
walletType ? getExternalWalletProviderName(walletType) : ''

const onClickRetry = () => {
actions.hideRedirectModal()
Expand Down
1 change: 1 addition & 0 deletions components/brave_rewards/resources/page/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface State {
| 'error'
| 'hide'
| 'show'
modalRedirectProvider: string
modalReset: boolean
modalAdsHistory: boolean
adsSettings: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function defaultState (): Rewards.State {
ui: {
modalConnect: false,
modalRedirect: 'hide',
modalRedirectProvider: '',
modalReset: false,
modalAdsHistory: false,
adsSettings: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ const rewardsReducer: Reducer<Rewards.State | undefined> = (state: Rewards.State

chrome.send('brave_rewards.connectExternalWallet', [path, query])
ui.modalRedirect = 'show'
// The first non-empty path segment contains the wallet provider type.
ui.modalRedirectProvider = path.replace(/^\//, '').split('/')[0] || ''

state = { ...state, ui }
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const reduxState: Rewards.ApplicationState = {
ui: {
modalConnect: false,
modalRedirect: 'hide',
modalRedirectProvider: '',
modalReset: false,
modalAdsHistory: false,
adsSettings: false,
Expand Down