1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Fix #19393 - Add indicator for Refresh list on tokens screen (#19952)

This commit is contained in:
David Walsh 2023-07-11 10:43:39 -05:00 committed by GitHub
parent 129f6f3f64
commit 145280374d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 8 deletions

View File

@ -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>

View File

@ -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', () => {

View File

@ -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]);