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