mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
parent
129f6f3f64
commit
145280374d
@ -1,5 +1,5 @@
|
|||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
@ -26,6 +26,7 @@ export const ImportTokenLink = ({ className, ...props }) => {
|
|||||||
const trackEvent = useContext(MetaMetricsContext);
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
const t = useI18nContext();
|
const t = useI18nContext();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const isTokenDetectionSupported = useSelector(getIsTokenDetectionSupported);
|
const isTokenDetectionSupported = useSelector(getIsTokenDetectionSupported);
|
||||||
const isTokenDetectionInactiveOnMainnet = useSelector(
|
const isTokenDetectionInactiveOnMainnet = useSelector(
|
||||||
@ -68,7 +69,7 @@ export const ImportTokenLink = ({ className, ...props }) => {
|
|||||||
size={Size.MD}
|
size={Size.MD}
|
||||||
startIconName={IconName.Refresh}
|
startIconName={IconName.Refresh}
|
||||||
data-testid="refresh-list-button"
|
data-testid="refresh-list-button"
|
||||||
onClick={() => detectNewTokens()}
|
onClick={() => dispatch(detectNewTokens())}
|
||||||
>
|
>
|
||||||
{t('refreshList')}
|
{t('refreshList')}
|
||||||
</ButtonLink>
|
</ButtonLink>
|
||||||
|
@ -19,7 +19,7 @@ jest.mock('react-router-dom', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
jest.mock('../../../store/actions.ts', () => ({
|
jest.mock('../../../store/actions.ts', () => ({
|
||||||
detectNewTokens: jest.fn(),
|
detectNewTokens: jest.fn().mockReturnValue({ type: '' }),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('Import Token Link', () => {
|
describe('Import Token Link', () => {
|
||||||
|
@ -2990,6 +2990,22 @@ export function setOpenSeaEnabled(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DetectTokenController
|
||||||
|
export function detectNewTokens(): ThunkAction<
|
||||||
|
void,
|
||||||
|
MetaMaskReduxState,
|
||||||
|
unknown,
|
||||||
|
AnyAction
|
||||||
|
> {
|
||||||
|
return async (dispatch: MetaMaskReduxDispatch) => {
|
||||||
|
dispatch(showLoadingIndication());
|
||||||
|
log.debug(`background.detectNewTokens`);
|
||||||
|
await submitRequestToBackground('detectNewTokens');
|
||||||
|
dispatch(hideLoadingIndication());
|
||||||
|
await forceUpdateMetamaskState(dispatch);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function detectNfts(): ThunkAction<
|
export function detectNfts(): ThunkAction<
|
||||||
void,
|
void,
|
||||||
MetaMaskReduxState,
|
MetaMaskReduxState,
|
||||||
@ -4287,11 +4303,6 @@ export function dismissSmartTransactionsErrorMessage(): Action {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// DetectTokenController
|
|
||||||
export async function detectNewTokens() {
|
|
||||||
return submitRequestToBackground('detectNewTokens');
|
|
||||||
}
|
|
||||||
|
|
||||||
// App state
|
// App state
|
||||||
export function hideTestNetMessage() {
|
export function hideTestNetMessage() {
|
||||||
return submitRequestToBackground('setShowTestnetMessageInDropdown', [false]);
|
return submitRequestToBackground('setShowTestnetMessageInDropdown', [false]);
|
||||||
|
Loading…
Reference in New Issue
Block a user