@@ -52,9 +52,9 @@ import {
5252 RESTORE_VAULT_ROUTE ,
5353 CONNECTED_ROUTE ,
5454 CONNECTED_ACCOUNTS_ROUTE ,
55- AWAITING_SWAP_ROUTE ,
56- PREPARE_SWAP_ROUTE ,
57- CROSS_CHAIN_SWAP_ROUTE ,
55+ // AWAITING_SWAP_ROUTE,
56+ // PREPARE_SWAP_ROUTE,
57+ // CROSS_CHAIN_SWAP_ROUTE,
5858 ONBOARDING_REVIEW_SRP_ROUTE ,
5959} from '../../helpers/constants/routes' ;
6060import ZENDESK_URLS from '../../helpers/constants/zendesk-url' ;
@@ -66,7 +66,7 @@ import {
6666} from '../../../shared/lib/ui-utils' ;
6767import { AccountOverview } from '../../components/multichain' ;
6868import { setEditedNetwork } from '../../store/actions' ;
69- import { getConfirmationRoute } from '../confirmations/hooks/useConfirmationNavigation' ;
69+ // import { getConfirmationRoute } from '../confirmations/hooks/useConfirmationNavigation';
7070import PasswordOutdatedModal from '../../components/app/password-outdated-modal' ;
7171import ShieldEntryModal from '../../components/app/shield-entry-modal' ;
7272///: BEGIN:ONLY_INCLUDE_IF(build-beta)
@@ -116,7 +116,7 @@ export default class Home extends PureComponent {
116116 showUpdateModal : PropTypes . bool . isRequired ,
117117 newNetworkAddedConfigurationId : PropTypes . string ,
118118 isNotification : PropTypes . bool . isRequired ,
119- isSidepanel : PropTypes . bool . isRequired ,
119+ // isSidepanel: PropTypes.bool.isRequired,
120120 // This prop is used in the `shouldCloseNotificationPopup` function
121121 // eslint-disable-next-line react/no-unused-prop-types
122122 totalUnapprovedCount : PropTypes . number . isRequired ,
@@ -159,7 +159,7 @@ export default class Home extends PureComponent {
159159 clearNewNetworkAdded : PropTypes . func ,
160160 clearEditedNetwork : PropTypes . func ,
161161 setActiveNetwork : PropTypes . func ,
162- hasAllowedPopupRedirectApprovals : PropTypes . bool . isRequired ,
162+ // hasAllowedPopupRedirectApprovals: PropTypes.bool.isRequired,
163163 useExternalServices : PropTypes . bool ,
164164 setBasicFunctionalityModalOpen : PropTypes . func ,
165165 fetchBuyableChains : PropTypes . func . isRequired ,
@@ -181,83 +181,87 @@ export default class Home extends PureComponent {
181181 state = {
182182 canShowBlockageNotification : true ,
183183 notificationClosing : false ,
184- redirecting : false ,
184+ // redirecting: false, // REMOVED: ConfirmationHandler now handles navigation
185185 } ;
186186
187187 constructor ( props ) {
188188 super ( props ) ;
189189
190- const {
191- attemptCloseNotificationPopup ,
192- haveSwapsQuotes ,
193- haveBridgeQuotes ,
194- isNotification ,
195- pendingApprovals ,
196- showAwaitingSwapScreen ,
197- swapsFetchParams ,
198- location ,
199- navState ,
200- } = this . props ;
201- // Read stayOnHomePage from both v5 location.state and v5-compat navState
202- const stayOnHomePage =
203- Boolean ( location ?. state ?. stayOnHomePage ) ||
204- Boolean ( navState ?. stayOnHomePage ) ;
190+ // REMOVED: Navigation logic moved to ConfirmationHandler
191+ // const {
192+ // attemptCloseNotificationPopup ,
193+ // haveSwapsQuotes ,
194+ // haveBridgeQuotes ,
195+ // isNotification ,
196+ // pendingApprovals ,
197+ // showAwaitingSwapScreen ,
198+ // swapsFetchParams ,
199+ // location ,
200+ // navState,
201+ // } = this.props;
202+ // const stayOnHomePage =
203+ // Boolean(location?.state?.stayOnHomePage) ||
204+ // Boolean(navState?.stayOnHomePage);
205205
206206 if ( shouldCloseNotificationPopup ( props ) ) {
207207 this . state . notificationClosing = true ;
208- attemptCloseNotificationPopup ( ) ;
209- } else if (
210- pendingApprovals . length ||
211- ( ! isNotification &&
212- ! stayOnHomePage &&
213- ( showAwaitingSwapScreen ||
214- haveSwapsQuotes ||
215- swapsFetchParams ||
216- haveBridgeQuotes ) )
217- ) {
218- this . state . redirecting = true ;
208+ props . attemptCloseNotificationPopup ( ) ;
219209 }
220- }
221-
222- checkStatusAndNavigate ( ) {
223- const {
224- history,
225- isNotification,
226- haveSwapsQuotes,
227- haveBridgeQuotes,
228- showAwaitingSwapScreen,
229- swapsFetchParams,
230- location,
231- pendingApprovals,
232- hasApprovalFlows,
233- navState,
234- } = this . props ;
235- // Read stayOnHomePage from both v5 location.state and v5-compat navState
236- const stayOnHomePage =
237- Boolean ( location ?. state ?. stayOnHomePage ) ||
238- Boolean ( navState ?. stayOnHomePage ) ;
239210
240- const canRedirect = ! isNotification && ! stayOnHomePage ;
241- if ( canRedirect && showAwaitingSwapScreen ) {
242- history . push ( AWAITING_SWAP_ROUTE ) ;
243- } else if ( canRedirect && ( haveSwapsQuotes || swapsFetchParams ) ) {
244- history . push ( PREPARE_SWAP_ROUTE ) ;
245- } else if ( canRedirect && haveBridgeQuotes ) {
246- history . push ( CROSS_CHAIN_SWAP_ROUTE + PREPARE_SWAP_ROUTE ) ;
247- } else if ( pendingApprovals . length || hasApprovalFlows ) {
248- const url = getConfirmationRoute (
249- pendingApprovals ?. [ 0 ] ?. id ,
250- pendingApprovals ,
251- hasApprovalFlows ,
252- '' , // queryString
253- ) ;
254-
255- if ( url ) {
256- history . replace ( url ) ;
257- }
258- }
211+ // REMOVED: Navigation logic moved to ConfirmationHandler
212+ // } else if (
213+ // pendingApprovals.length ||
214+ // (!isNotification &&
215+ // !stayOnHomePage &&
216+ // (showAwaitingSwapScreen ||
217+ // haveSwapsQuotes ||
218+ // swapsFetchParams ||
219+ // haveBridgeQuotes))
220+ // ) {
221+ // this.state.redirecting = true;
222+ // }
259223 }
260224
225+ // MOVED TO ConfirmationHandler - this logic now runs globally
226+ // checkStatusAndNavigate() {
227+ // const {
228+ // history,
229+ // isNotification,
230+ // haveSwapsQuotes,
231+ // haveBridgeQuotes,
232+ // showAwaitingSwapScreen,
233+ // swapsFetchParams,
234+ // location,
235+ // pendingApprovals,
236+ // hasApprovalFlows,
237+ // navState,
238+ // } = this.props;
239+ // // Read stayOnHomePage from both v5 location.state and v5-compat navState
240+ // const stayOnHomePage =
241+ // Boolean(location?.state?.stayOnHomePage) ||
242+ // Boolean(navState?.stayOnHomePage);
243+
244+ // const canRedirect = !isNotification && !stayOnHomePage;
245+ // if (canRedirect && showAwaitingSwapScreen) {
246+ // history.push(AWAITING_SWAP_ROUTE);
247+ // } else if (canRedirect && (haveSwapsQuotes || swapsFetchParams)) {
248+ // history.push(PREPARE_SWAP_ROUTE);
249+ // } else if (canRedirect && haveBridgeQuotes) {
250+ // history.push(CROSS_CHAIN_SWAP_ROUTE + PREPARE_SWAP_ROUTE);
251+ // } else if (pendingApprovals.length || hasApprovalFlows) {
252+ // const url = getConfirmationRoute(
253+ // pendingApprovals?.[0]?.id,
254+ // pendingApprovals,
255+ // hasApprovalFlows,
256+ // '', // queryString
257+ // );
258+
259+ // if (url) {
260+ // history.replace(url);
261+ // }
262+ // }
263+ // }
264+
261265 checkRedirectAfterDefaultPage ( ) {
262266 const {
263267 redirectAfterDefaultPage,
@@ -281,7 +285,7 @@ export default class Home extends PureComponent {
281285 }
282286
283287 componentDidMount ( ) {
284- this . checkStatusAndNavigate ( ) ;
288+ // this.checkStatusAndNavigate();
285289
286290 this . props . fetchBuyableChains ( ) ;
287291
@@ -307,12 +311,12 @@ export default class Home extends PureComponent {
307311 componentDidUpdate ( _prevProps , prevState ) {
308312 const {
309313 attemptCloseNotificationPopup,
310- isNotification,
311- hasAllowedPopupRedirectApprovals,
314+ // isNotification,
315+ // hasAllowedPopupRedirectApprovals,
312316 newNetworkAddedConfigurationId,
313317 setActiveNetwork,
314318 clearNewNetworkAdded,
315- isSidepanel,
319+ // isSidepanel,
316320 pendingShieldCohort,
317321 evaluateCohortEligibility,
318322 setPendingShieldCohort,
@@ -334,13 +338,14 @@ export default class Home extends PureComponent {
334338
335339 if ( notificationClosing && ! prevState . notificationClosing ) {
336340 attemptCloseNotificationPopup ( ) ;
337- } else if (
338- isNotification ||
339- hasAllowedPopupRedirectApprovals ||
340- isSidepanel
341- ) {
342- this . checkStatusAndNavigate ( ) ;
343341 }
342+ // else if (
343+ // isNotification ||
344+ // hasAllowedPopupRedirectApprovals ||
345+ // isSidepanel
346+ // ) {
347+ // this.checkStatusAndNavigate();
348+ // }
344349
345350 // Check for pending Shield cohort evaluation if user is signed in
346351 if ( pendingShieldCohort && evaluateCohortEligibility && isSignedIn ) {
@@ -872,9 +877,39 @@ export default class Home extends PureComponent {
872877 isSocialLoginFlow,
873878 } = this . props ;
874879
880+ const {
881+ pendingApprovals,
882+ hasApprovalFlows,
883+ haveSwapsQuotes,
884+ swapsFetchParams,
885+ haveBridgeQuotes,
886+ showAwaitingSwapScreen,
887+ isNotification,
888+ location,
889+ navState,
890+ } = this . props ;
891+
892+ // Read stayOnHomePage from both v5 location.state and v5-compat navState
893+ const stayOnHomePage =
894+ Boolean ( location ?. state ?. stayOnHomePage ) ||
895+ Boolean ( navState ?. stayOnHomePage ) ;
896+
897+ // Don't render Home content when there are pending approvals/swaps
898+ // to prevent crashes from incomplete state
899+ // ConfirmationHandler will handle the navigation
900+ const shouldNotRenderContent =
901+ pendingApprovals . length ||
902+ hasApprovalFlows ||
903+ ( ! isNotification &&
904+ ! stayOnHomePage &&
905+ ( showAwaitingSwapScreen ||
906+ haveSwapsQuotes ||
907+ swapsFetchParams ||
908+ haveBridgeQuotes ) ) ;
909+
875910 if ( forgottenPassword ) {
876911 return < Redirect to = { { pathname : RESTORE_VAULT_ROUTE } } /> ;
877- } else if ( this . state . notificationClosing || this . state . redirecting ) {
912+ } else if ( this . state . notificationClosing || shouldNotRenderContent ) {
878913 return null ;
879914 }
880915
0 commit comments