Skip to content

Commit

Permalink
Fix clicking outside modal to close
Browse files Browse the repository at this point in the history
  • Loading branch information
jorbuedo committed Jun 13, 2024
1 parent 45ce876 commit 47fe823
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import LinearGradient from 'react-native-linear-gradient'

import {Button, Icon, useModal} from '../../components'
import {Space} from '../../components/Space/Space'
import {useSelectedWallet} from '../../features/WalletManager/Context/SelectedWalletContext'
import {formatTimeSpan} from '../../yoroi-wallets/utils'
import {usePoolTransitionContext} from './PoolTransitionProvider'
import {useStrings} from './usePoolTransition'

export const PoolTransitionModal = ({
Expand All @@ -23,11 +21,8 @@ export const PoolTransitionModal = ({
const strings = useStrings()

const {closeModal} = useModal()
const wallet = useSelectedWallet()
const [, setClosedWallets] = usePoolTransitionContext()

const handleClose = () => {
setClosedWallets((closedWallets) => [wallet.id, ...closedWallets])
const handleOnSkip = () => {
closeModal()
}

Expand All @@ -37,7 +32,7 @@ export const PoolTransitionModal = ({
await onContinue()
} finally {
setIsLoading(false)
handleClose()
closeModal()
}
}

Expand Down Expand Up @@ -138,7 +133,7 @@ export const PoolTransitionModal = ({
<Space height="xl" />

<Actions>
<Button outline title={strings.skipNoRewards} textStyles={styles.outlineButton} onPress={handleClose} />
<Button outline title={strings.skipNoRewards} textStyles={styles.outlineButton} onPress={handleOnSkip} />

<Button
shelleyTheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,30 @@ import {usePoolTransition, useStrings} from './usePoolTransition'
export const usePoolTransitionModal = () => {
const {poolTransition, isPoolRetiring, isLoading, navigateToUpdate} = usePoolTransition()
const wallet = useSelectedWallet()
const [closedWallets] = usePoolTransitionContext()
const [shownWallets, setShownWallets] = usePoolTransitionContext()
const {openModal} = useModal()
const strings = useStrings()
const modalHeight = 700

React.useEffect(() => {
if (!closedWallets.includes(wallet.id) && isPoolRetiring && poolTransition !== null) {
if (!shownWallets.includes(wallet.id) && isPoolRetiring && poolTransition !== null) {
openModal(
strings.title,
<PoolTransitionModal poolTransition={poolTransition} onContinue={navigateToUpdate} />,
modalHeight,
)
setShownWallets(() => [wallet.id, ...shownWallets])
}
}, [
closedWallets,
shownWallets,
isPoolRetiring,
modalHeight,
navigateToUpdate,
openModal,
poolTransition,
strings.title,
wallet.id,
setShownWallets,
])

return {isLoading}
Expand Down

0 comments on commit 47fe823

Please sign in to comment.