Skip to content

Commit

Permalink
Fix Rewards connection modal retry (uplift to 1.62.x) (#21509)
Browse files Browse the repository at this point in the history
Uplift of #21472 (squashed) to beta
  • Loading branch information
brave-builds authored Jan 12, 2024
1 parent 92c88bc commit d68e351
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
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

0 comments on commit d68e351

Please sign in to comment.