@@ -94,6 +94,7 @@ import {
9494} from '../../hooks/useNetworksByNamespace/useNetworksByNamespace' ;
9595import { useNetworkSelection } from '../../hooks/useNetworkSelection/useNetworkSelection' ;
9696import { useIsOnBridgeRoute } from '../../UI/Bridge/hooks/useIsOnBridgeRoute' ;
97+ import { shouldShowNetworkListToast } from './utils' ;
9798
9899const Stack = createStackNavigator ( ) ;
99100
@@ -298,11 +299,9 @@ const Main = (props) => {
298299 ) ;
299300
300301 // Emit network addition/deletion toast if network list changes
301- // Bridge routes are skipped as they interfere with bridge UI
302302 if (
303303 previousNetworkValues . length &&
304- currentNetworkValues . length !== previousNetworkValues . length &&
305- ! isOnBridgeRoute
304+ currentNetworkValues . length !== previousNetworkValues . length
306305 ) {
307306 // Find the newly added network by comparing chainIds
308307 const newNetwork = currentNetworkValues . find (
@@ -318,27 +317,33 @@ const Main = (props) => {
318317 ) ,
319318 ) ;
320319
321- toastRef ?. current ?. showToast ( {
322- variant : ToastVariants . Plain ,
323- labelOptions : [
324- {
325- label : `${
326- ( newNetwork ?. name || deletedNetwork ?. name ) ??
327- strings ( 'asset_details.network' )
328- } `,
329- isBold : true ,
330- } ,
331- {
332- label : deletedNetwork
333- ? strings ( 'toast.network_removed' )
334- : strings ( 'toast.network_added' ) ,
335- } ,
336- ] ,
337- networkImageSource : networkImage ,
320+ const shouldShowToast = shouldShowNetworkListToast ( {
321+ newNetworkChainId : newNetwork ?. chainId ,
322+ hasDeletedNetwork : Boolean ( deletedNetwork ) ,
338323 } ) ;
324+ if ( shouldShowToast ) {
325+ toastRef ?. current ?. showToast ( {
326+ variant : ToastVariants . Plain ,
327+ labelOptions : [
328+ {
329+ label : `${
330+ ( deletedNetwork ?. name || newNetwork ?. name ) ??
331+ strings ( 'asset_details.network' )
332+ } `,
333+ isBold : true ,
334+ } ,
335+ {
336+ label : deletedNetwork
337+ ? strings ( 'toast.network_removed' )
338+ : strings ( 'toast.network_added' ) ,
339+ } ,
340+ ] ,
341+ networkImageSource : networkImage ,
342+ } ) ;
343+ }
339344 }
340345 previousNetworkConfigurations . current = networkConfigurations ;
341- } , [ isOnBridgeRoute , networkConfigurations , networkImage , toastRef ] ) ;
346+ } , [ networkConfigurations , networkImage , toastRef ] ) ;
342347
343348 useEffect ( ( ) => {
344349 if ( locale . current !== I18n . locale ) {
0 commit comments