-
Couldn't load subscription status.
- Fork 5.4k
refactor: migrate components/app files to v5-compat #37204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import React, { useContext, useEffect, useState } from 'react'; | ||
| import { useSelector } from 'react-redux'; | ||
| import { useHistory } from 'react-router-dom'; | ||
| import { useNavigate } from 'react-router-dom-v5-compat'; | ||
| import { I18nContext } from '../../../../contexts/i18n'; | ||
| import { useModalProps } from '../../../../hooks/useModalProps'; | ||
| import { useMetamaskNotificationsContext } from '../../../../contexts/metamask-notifications/metamask-notifications'; | ||
|
|
@@ -40,7 +40,7 @@ import { | |
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| export default function TurnOnMetamaskNotifications() { | ||
| const { hideModal } = useModalProps(); | ||
| const history = useHistory(); | ||
| const navigate = useNavigate(); | ||
| const t = useContext(I18nContext); | ||
| const trackEvent = useContext(MetaMetricsContext); | ||
| const { listNotifications } = useMetamaskNotificationsContext(); | ||
|
|
@@ -99,11 +99,11 @@ export default function TurnOnMetamaskNotifications() { | |
|
|
||
| useEffect(() => { | ||
| if (isNotificationEnabled && !error) { | ||
| history.push(NOTIFICATIONS_ROUTE); | ||
| navigate(NOTIFICATIONS_ROUTE); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| hideModal(); | ||
| listNotifications(); | ||
| } | ||
| }, [isNotificationEnabled, error, history, hideModal, listNotifications]); | ||
| }, [isNotificationEnabled, error, navigate, hideModal, listNotifications]); | ||
|
|
||
| const privacyLink = ( | ||
| <Text | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,12 +2,11 @@ | |
|
|
||
| import React, { useEffect, useMemo, useState } from 'react'; | ||
| import { useDispatch, useSelector } from 'react-redux'; | ||
| import { useHistory, useLocation } from 'react-router-dom'; | ||
| import { useNavigate } from 'react-router-dom-v5-compat'; | ||
| import classnames from 'classnames'; | ||
| import { getAllScopesFromCaip25CaveatValue } from '@metamask/chain-agnostic-permission'; | ||
| import { AvatarAccountSize } from '@metamask/design-system-react'; | ||
| import { PRODUCT_TYPES } from '@metamask/subscription-controller'; | ||
| import { useNavigate } from 'react-router-dom-v5-compat'; | ||
| import { MILLISECOND, SECOND } from '../../../../shared/constants/time'; | ||
| import { | ||
| PRIVACY_POLICY_LINK, | ||
|
|
@@ -98,14 +97,15 @@ import { | |
| setShieldEndingToastLastClickedOrClosed, | ||
| } from './utils'; | ||
|
|
||
| export function ToastMaster() { | ||
| const location = useLocation(); | ||
| export function ToastMaster({ location } = {}) { | ||
| const isMultichainAccountsFeatureState2Enabled = useSelector( | ||
| getIsMultichainAccountsState2Enabled, | ||
| ); | ||
|
|
||
| const onHomeScreen = location.pathname === DEFAULT_ROUTE; | ||
| const onSettingsScreen = location.pathname.startsWith(SETTINGS_ROUTE); | ||
| // Use passed location or fallback to DEFAULT_ROUTE | ||
| const currentPathname = location?.pathname ?? DEFAULT_ROUTE; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| const onHomeScreen = currentPathname === DEFAULT_ROUTE; | ||
| const onSettingsScreen = currentPathname.startsWith(SETTINGS_ROUTE); | ||
|
|
||
| if (onHomeScreen) { | ||
| return ( | ||
|
|
@@ -391,7 +391,7 @@ function PermittedNetworkToast() { | |
| const activeTabOrigin = useSelector(getOriginOfCurrentTab); | ||
| const dappActiveNetwork = useSelector(getDappActiveNetwork); | ||
| const safeEncodedHost = encodeURIComponent(activeTabOrigin); | ||
| const history = useHistory(); | ||
| const navigate = useNavigate(); | ||
|
|
||
| // Use dapp's active network if available, otherwise fall back to global network | ||
| const displayNetwork = dappActiveNetwork || currentNetwork; | ||
|
|
@@ -429,7 +429,7 @@ function PermittedNetworkToast() { | |
| actionText={t('editPermissions')} | ||
| onActionClick={() => { | ||
| dispatch(hidePermittedNetworkToast()); | ||
| history.push(`${REVIEW_PERMISSIONS}/${safeEncodedHost}`); | ||
| navigate(`${REVIEW_PERMISSIONS}/${safeEncodedHost}`); | ||
| }} | ||
| onClose={() => dispatch(hidePermittedNetworkToast())} | ||
| /> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.