@@ -3,28 +3,34 @@ import { useAddPopup, useRemovePopup } from 'state/application/hooks'
3
3
import { PopupType } from 'state/application/reducer'
4
4
import { SwapTab } from 'uniswap/src/types/screens/interface'
5
5
6
+ type SwapNetworkNotificationCallbackType = {
7
+ chainId ?: number // The chainId to show notif for, can be input or output chain
8
+ prevChainId ?: number // The previous chainId the user was swapping on, not used for bridging notifications
9
+ outputChainId ?: number // The output chainId the user is swapping to
10
+ }
11
+
6
12
export function useShowSwapNetworkNotification ( ) {
7
13
const addPopup = useAddPopup ( )
8
14
const removePopup = useRemovePopup ( )
9
15
10
16
return useCallback (
11
- ( chainId ?: number , prevChainId ?: number ) => {
12
- if ( ! chainId || chainId === prevChainId ) {
17
+ ( { chainId , prevChainId, outputChainId } : SwapNetworkNotificationCallbackType ) => {
18
+ if ( ! chainId || chainId === prevChainId || chainId === outputChainId ) {
13
19
return
14
20
}
15
- const isBridgeNotification = chainId && prevChainId
21
+ const isBridgeNotification = chainId && outputChainId
16
22
removePopup ( `switchNetwork-${ prevChainId } ` )
17
23
if ( isBridgeNotification ) {
18
24
addPopup (
19
25
{
20
26
type : PopupType . Bridge ,
21
27
inputChainId : chainId ,
22
- outputChainId : prevChainId ,
28
+ outputChainId,
23
29
} ,
24
- `bridge-${ chainId } -to-${ prevChainId } ` ,
30
+ `bridge-${ chainId } -to-${ outputChainId } ` ,
25
31
3000 ,
26
32
)
27
- } else {
33
+ } else if ( prevChainId ) {
28
34
addPopup (
29
35
{
30
36
type : PopupType . SwitchNetwork ,
0 commit comments