mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Redirect to homepage from Swaps asap without waiting for state cleanup (#20236)
This commit is contained in:
parent
4e52fe2494
commit
2ad2827bab
@ -154,6 +154,7 @@ export default class Home extends PureComponent {
|
|||||||
haveSwapsQuotes: PropTypes.bool.isRequired,
|
haveSwapsQuotes: PropTypes.bool.isRequired,
|
||||||
showAwaitingSwapScreen: PropTypes.bool.isRequired,
|
showAwaitingSwapScreen: PropTypes.bool.isRequired,
|
||||||
swapsFetchParams: PropTypes.object,
|
swapsFetchParams: PropTypes.object,
|
||||||
|
location: PropTypes.object,
|
||||||
shouldShowWeb3ShimUsageNotification: PropTypes.bool.isRequired,
|
shouldShowWeb3ShimUsageNotification: PropTypes.bool.isRequired,
|
||||||
setWeb3ShimUsageAlertDismissed: PropTypes.func.isRequired,
|
setWeb3ShimUsageAlertDismissed: PropTypes.func.isRequired,
|
||||||
originOfCurrentTab: PropTypes.string,
|
originOfCurrentTab: PropTypes.string,
|
||||||
@ -218,7 +219,9 @@ export default class Home extends PureComponent {
|
|||||||
hasWatchNftPendingApprovals,
|
hasWatchNftPendingApprovals,
|
||||||
swapsFetchParams,
|
swapsFetchParams,
|
||||||
hasTransactionPendingApprovals,
|
hasTransactionPendingApprovals,
|
||||||
|
location,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
const stayOnHomePage = Boolean(location?.state?.stayOnHomePage);
|
||||||
|
|
||||||
if (shouldCloseNotificationPopup(props)) {
|
if (shouldCloseNotificationPopup(props)) {
|
||||||
this.state.notificationClosing = true;
|
this.state.notificationClosing = true;
|
||||||
@ -229,6 +232,7 @@ export default class Home extends PureComponent {
|
|||||||
hasWatchTokenPendingApprovals ||
|
hasWatchTokenPendingApprovals ||
|
||||||
hasWatchNftPendingApprovals ||
|
hasWatchNftPendingApprovals ||
|
||||||
(!isNotification &&
|
(!isNotification &&
|
||||||
|
!stayOnHomePage &&
|
||||||
(showAwaitingSwapScreen || haveSwapsQuotes || swapsFetchParams))
|
(showAwaitingSwapScreen || haveSwapsQuotes || swapsFetchParams))
|
||||||
) {
|
) {
|
||||||
this.state.redirecting = true;
|
this.state.redirecting = true;
|
||||||
@ -289,19 +293,22 @@ export default class Home extends PureComponent {
|
|||||||
haveSwapsQuotes,
|
haveSwapsQuotes,
|
||||||
showAwaitingSwapScreen,
|
showAwaitingSwapScreen,
|
||||||
swapsFetchParams,
|
swapsFetchParams,
|
||||||
|
location,
|
||||||
pendingConfirmations,
|
pendingConfirmations,
|
||||||
hasApprovalFlows,
|
hasApprovalFlows,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
const stayOnHomePage = Boolean(location?.state?.stayOnHomePage);
|
||||||
|
|
||||||
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||||
this.shouldCloseCurrentWindow();
|
this.shouldCloseCurrentWindow();
|
||||||
///: END:ONLY_INCLUDE_IN
|
///: END:ONLY_INCLUDE_IN
|
||||||
|
|
||||||
if (!isNotification && showAwaitingSwapScreen) {
|
const canRedirect = !isNotification && !stayOnHomePage;
|
||||||
|
if (canRedirect && showAwaitingSwapScreen) {
|
||||||
history.push(AWAITING_SWAP_ROUTE);
|
history.push(AWAITING_SWAP_ROUTE);
|
||||||
} else if (!isNotification && haveSwapsQuotes) {
|
} else if (canRedirect && haveSwapsQuotes) {
|
||||||
history.push(VIEW_QUOTE_ROUTE);
|
history.push(VIEW_QUOTE_ROUTE);
|
||||||
} else if (!isNotification && swapsFetchParams) {
|
} else if (canRedirect && swapsFetchParams) {
|
||||||
history.push(BUILD_QUOTE_ROUTE);
|
history.push(BUILD_QUOTE_ROUTE);
|
||||||
} else if (firstPermissionsRequestId) {
|
} else if (firstPermissionsRequestId) {
|
||||||
history.push(`${CONNECT_ROUTE}/${firstPermissionsRequestId}`);
|
history.push(`${CONNECT_ROUTE}/${firstPermissionsRequestId}`);
|
||||||
|
@ -349,9 +349,12 @@ export default function Swap() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const redirectToDefaultRoute = async () => {
|
const redirectToDefaultRoute = async () => {
|
||||||
|
history.push({
|
||||||
|
pathname: DEFAULT_ROUTE,
|
||||||
|
state: { stayOnHomePage: true },
|
||||||
|
});
|
||||||
dispatch(clearSwapsState());
|
dispatch(clearSwapsState());
|
||||||
await dispatch(resetBackgroundSwapsState());
|
await dispatch(resetBackgroundSwapsState());
|
||||||
history.push(DEFAULT_ROUTE);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user