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

Latest update conversion date - issue #10741 (#12422)

* conversion date fix

* update in settings conversion date - no internet

* update conversionDate fetch - setting container

* no currency date message updated
This commit is contained in:
igorms-cons 2021-12-02 13:18:09 +01:00 committed by GitHub
parent 9e2935dd55
commit 6dbf6e3ab3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 8 deletions

View File

@ -1782,6 +1782,9 @@
"noAlreadyHaveSeed": { "noAlreadyHaveSeed": {
"message": "No, I already have a Secret Recovery Phrase" "message": "No, I already have a Secret Recovery Phrase"
}, },
"noConversionDateAvailable": {
"message": "No Currency Conversion Date Available"
},
"noConversionRateAvailable": { "noConversionRateAvailable": {
"message": "No Conversion Rate Available" "message": "No Conversion Rate Available"
}, },

View File

@ -37,24 +37,32 @@ export default class SettingsTab extends PureComponent {
currentLocale: PropTypes.string, currentLocale: PropTypes.string,
useBlockie: PropTypes.bool, useBlockie: PropTypes.bool,
currentCurrency: PropTypes.string, currentCurrency: PropTypes.string,
conversionDate: PropTypes.number,
nativeCurrency: PropTypes.string, nativeCurrency: PropTypes.string,
useNativeCurrencyAsPrimaryCurrency: PropTypes.bool, useNativeCurrencyAsPrimaryCurrency: PropTypes.bool,
setUseNativeCurrencyAsPrimaryCurrencyPreference: PropTypes.func, setUseNativeCurrencyAsPrimaryCurrencyPreference: PropTypes.func,
hideZeroBalanceTokens: PropTypes.bool, hideZeroBalanceTokens: PropTypes.bool,
setHideZeroBalanceTokens: PropTypes.func, setHideZeroBalanceTokens: PropTypes.func,
lastFetchedConversionDate: PropTypes.number,
}; };
renderCurrentConversion() { renderCurrentConversion() {
const { t } = this.context; const { t } = this.context;
const { currentCurrency, conversionDate, setCurrentCurrency } = this.props; const {
currentCurrency,
setCurrentCurrency,
lastFetchedConversionDate,
} = this.props;
return ( return (
<div className="settings-page__content-row"> <div className="settings-page__content-row">
<div className="settings-page__content-item"> <div className="settings-page__content-item">
<span>{t('currencyConversion')}</span> <span>{t('currencyConversion')}</span>
<span className="settings-page__content-description"> <span className="settings-page__content-description">
{t('updatedWithDate', [Date(conversionDate)])} {lastFetchedConversionDate
? t('updatedWithDate', [
new Date(lastFetchedConversionDate * 1000).toString(),
])
: t('noConversionDateAvailable')}
</span> </span>
</div> </div>
<div className="settings-page__content-item"> <div className="settings-page__content-item">

View File

@ -10,14 +10,13 @@ import {
import { getPreferences } from '../../../selectors'; import { getPreferences } from '../../../selectors';
import SettingsTab from './settings-tab.component'; import SettingsTab from './settings-tab.component';
const mapStateToProps = (state) => { const mapStateToProps = (state, ownProps) => {
const { const {
appState: { warning }, appState: { warning },
metamask, metamask,
} = state; } = state;
const { const {
currentCurrency, currentCurrency,
conversionDate,
nativeCurrency, nativeCurrency,
useBlockie, useBlockie,
currentLocale, currentLocale,
@ -27,15 +26,17 @@ const mapStateToProps = (state) => {
hideZeroBalanceTokens, hideZeroBalanceTokens,
} = getPreferences(state); } = getPreferences(state);
const { lastFetchedConversionDate } = ownProps;
return { return {
warning, warning,
currentLocale, currentLocale,
currentCurrency, currentCurrency,
conversionDate,
nativeCurrency, nativeCurrency,
useBlockie, useBlockie,
useNativeCurrencyAsPrimaryCurrency, useNativeCurrencyAsPrimaryCurrency,
hideZeroBalanceTokens, hideZeroBalanceTokens,
lastFetchedConversionDate,
}; };
}; };

View File

@ -41,12 +41,32 @@ class SettingsPage extends PureComponent {
initialBreadCrumbKey: PropTypes.string, initialBreadCrumbKey: PropTypes.string,
mostRecentOverviewPage: PropTypes.string.isRequired, mostRecentOverviewPage: PropTypes.string.isRequired,
addNewNetwork: PropTypes.bool, addNewNetwork: PropTypes.bool,
conversionDate: PropTypes.number,
}; };
static contextTypes = { static contextTypes = {
t: PropTypes.func, t: PropTypes.func,
}; };
state = {
lastFetchedConversionDate: null,
};
componentDidMount() {
this.handleConversionDate();
}
componentDidUpdate() {
this.handleConversionDate();
}
handleConversionDate() {
const { conversionDate } = this.props;
if (conversionDate !== null) {
this.setState({ lastFetchedConversionDate: conversionDate });
}
}
render() { render() {
const { const {
history, history,
@ -227,7 +247,16 @@ class SettingsPage extends PureComponent {
renderContent() { renderContent() {
return ( return (
<Switch> <Switch>
<Route exact path={GENERAL_ROUTE} component={SettingsTab} /> <Route
exact
path={GENERAL_ROUTE}
render={(routeProps) => (
<SettingsTab
{...routeProps}
lastFetchedConversionDate={this.state.lastFetchedConversionDate}
/>
)}
/>
<Route exact path={ABOUT_US_ROUTE} component={InfoTab} /> <Route exact path={ABOUT_US_ROUTE} component={InfoTab} />
<Route exact path={ADVANCED_ROUTE} component={AdvancedTab} /> <Route exact path={ADVANCED_ROUTE} component={AdvancedTab} />
<Route exact path={ALERTS_ROUTE} component={AlertsTab} /> <Route exact path={ALERTS_ROUTE} component={AlertsTab} />
@ -251,7 +280,14 @@ class SettingsPage extends PureComponent {
path={`${CONTACT_VIEW_ROUTE}/:id`} path={`${CONTACT_VIEW_ROUTE}/:id`}
component={ContactListTab} component={ContactListTab}
/> />
<Route component={SettingsTab} /> <Route
render={(routeProps) => (
<SettingsTab
{...routeProps}
lastFetchedConversionDate={this.state.lastFetchedConversionDate}
/>
)}
/>
</Switch> </Switch>
); );
} }

View File

@ -47,6 +47,10 @@ const ROUTES_TO_I18N_KEYS = {
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state, ownProps) => {
const { location } = ownProps; const { location } = ownProps;
const { pathname } = location; const { pathname } = location;
const {
metamask: { conversionDate },
} = state;
const pathNameTail = pathname.match(/[^/]+$/u)[0]; const pathNameTail = pathname.match(/[^/]+$/u)[0];
const isAddressEntryPage = pathNameTail.includes('0x'); const isAddressEntryPage = pathNameTail.includes('0x');
@ -91,6 +95,7 @@ const mapStateToProps = (state, ownProps) => {
initialBreadCrumbKey, initialBreadCrumbKey,
mostRecentOverviewPage: getMostRecentOverviewPage(state), mostRecentOverviewPage: getMostRecentOverviewPage(state),
addNewNetwork, addNewNetwork,
conversionDate,
}; };
}; };