-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(pool-transition) Fix modal reopening (#3299)
- Loading branch information
Showing
6 changed files
with
69 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
apps/wallet-mobile/src/Staking/PoolTransition/PoolTransitionProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react' | ||
|
||
const PoolTransitionContext = React.createContext< | ||
[string[], React.Dispatch<React.SetStateAction<string[]>>] | undefined | ||
>(undefined) | ||
|
||
export const PoolTransitionProvider = ({children}: {children: React.ReactNode}) => { | ||
const value = React.useState<Array<string>>([]) | ||
|
||
return <PoolTransitionContext.Provider value={value}>{children}</PoolTransitionContext.Provider> | ||
} | ||
|
||
export const usePoolTransitionContext = () => React.useContext(PoolTransitionContext) || missingProvider() | ||
|
||
const missingProvider = () => { | ||
throw new Error('PoolTransitionProvider is missing') | ||
} |
19 changes: 17 additions & 2 deletions
19
apps/wallet-mobile/src/Staking/PoolTransition/usePoolTransitionModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,39 @@ | ||
import * as React from 'react' | ||
|
||
import {useModal} from '../../components' | ||
import {useSelectedWallet} from '../../features/WalletManager/Context/SelectedWalletContext' | ||
import {PoolTransitionModal} from './PoolTransitionModal' | ||
import {usePoolTransitionContext} from './PoolTransitionProvider' | ||
import {usePoolTransition, useStrings} from './usePoolTransition' | ||
|
||
export const usePoolTransitionModal = () => { | ||
const {poolTransition, isPoolRetiring, isLoading, navigateToUpdate} = usePoolTransition() | ||
const wallet = useSelectedWallet() | ||
const [shownWallets, setShownWallets] = usePoolTransitionContext() | ||
const {openModal} = useModal() | ||
const strings = useStrings() | ||
const modalHeight = 700 | ||
|
||
React.useEffect(() => { | ||
if (isPoolRetiring && poolTransition !== null) { | ||
if (!shownWallets.includes(wallet.id) && isPoolRetiring && poolTransition !== null) { | ||
openModal( | ||
strings.title, | ||
<PoolTransitionModal poolTransition={poolTransition} onContinue={navigateToUpdate} />, | ||
modalHeight, | ||
) | ||
setShownWallets(() => [wallet.id, ...shownWallets]) | ||
} | ||
}, [isPoolRetiring, modalHeight, navigateToUpdate, openModal, poolTransition, strings.title]) | ||
}, [ | ||
shownWallets, | ||
isPoolRetiring, | ||
modalHeight, | ||
navigateToUpdate, | ||
openModal, | ||
poolTransition, | ||
strings.title, | ||
wallet.id, | ||
setShownWallets, | ||
]) | ||
|
||
return {isLoading} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2780,10 +2780,10 @@ | |
bignumber.js "^9.0.1" | ||
easy-crc "1.1.0" | ||
|
||
"@emurgo/[email protected]-alpha.8": | ||
version "0.15.5-alpha.8" | ||
resolved "https://registry.yarnpkg.com/@emurgo/yoroi-lib/-/yoroi-lib-0.15.5-alpha.8.tgz#71791392419f718d19256c4aaedd1ac8d3a37bbe" | ||
integrity sha512-avc0cwttCgEgBMflxKK2Kaxw4IbErLa+ezlWWgJ4iGN0fgHYcpY335xXd2g+cQmsRKpPyhNWWqPXafo6e8lT8Q== | ||
"@emurgo/[email protected]": | ||
version "0.15.5" | ||
resolved "https://registry.yarnpkg.com/@emurgo/yoroi-lib/-/yoroi-lib-0.15.5.tgz#534cf4b81376f2b185b73e05a2103d9712be4a8d" | ||
integrity sha512-Fq6MN/l5Na14d3LOsnT7xzKDky1ugbKxQ6+zzxchZkcF+w0OXGtK4sFGXccR47E7JhRLhjLqOzKSKhKGkTVt+A== | ||
dependencies: | ||
"@cardano-foundation/ledgerjs-hw-app-cardano" "^6.0.0" | ||
"@emurgo/cross-csl-core" "4.4.0" | ||
|