Fix threebox last updated proptype (#7375)

* Use child components for multiple notifications component

The multiple notifications component has been updated to take its child
components as children rather than as a props array, so that the child
components are never executed in the case where they aren't needed.

* Fix threebox last updated proptype
feature/default_network_editable
Mark Stacey 5 years ago committed by GitHub
parent 02aebc2e03
commit ec1f3fa19a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      ui/app/components/app/multiple-notifications/multiple-notifications.component.js
  2. 35
      ui/app/pages/home/home.component.js

@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
export default class MultipleNotifications extends PureComponent { export default class MultipleNotifications extends PureComponent {
static propTypes = { static propTypes = {
notifications: PropTypes.array, children: PropTypes.array,
classNames: PropTypes.array, classNames: PropTypes.array,
} }
@ -14,11 +14,10 @@ export default class MultipleNotifications extends PureComponent {
render () { render () {
const { showAll } = this.state const { showAll } = this.state
const { notifications, classNames = [] } = this.props const { children, classNames = [] } = this.props
const notificationsToBeRendered = notifications.filter(notificationConfig => notificationConfig.shouldBeRendered) const childrenToRender = children.filter(child => child)
if (childrenToRender.length === 0) {
if (notificationsToBeRendered.length === 0) {
return null return null
} }
@ -29,12 +28,12 @@ export default class MultipleNotifications extends PureComponent {
'home-notification-wrapper--show-first': !showAll, 'home-notification-wrapper--show-first': !showAll,
})} })}
> >
{ notificationsToBeRendered.map(notificationConfig => notificationConfig.component) } { childrenToRender }
<div <div
className="home-notification-wrapper__i-container" className="home-notification-wrapper__i-container"
onClick={() => this.setState({ showAll: !showAll })} onClick={() => this.setState({ showAll: !showAll })}
> >
{notificationsToBeRendered.length > 1 ? <i className={classnames('fa fa-sm fa-sort-amount-asc', { {childrenToRender.length > 1 ? <i className={classnames('fa fa-sm fa-sort-amount-asc', {
'flipped': !showAll, 'flipped': !showAll,
})} /> : null} })} /> : null}
</div> </div>

@ -42,7 +42,7 @@ export default class Home extends PureComponent {
selectedAddress: PropTypes.string, selectedAddress: PropTypes.string,
restoreFromThreeBox: PropTypes.func, restoreFromThreeBox: PropTypes.func,
setShowRestorePromptToFalse: PropTypes.func, setShowRestorePromptToFalse: PropTypes.func,
threeBoxLastUpdated: PropTypes.string, threeBoxLastUpdated: PropTypes.number,
} }
componentWillMount () { componentWillMount () {
@ -119,10 +119,10 @@ export default class Home extends PureComponent {
<TransactionView> <TransactionView>
<MultipleNotifications <MultipleNotifications
className className
notifications={[ >
{ {
shouldBeRendered: showPrivacyModeNotification, showPrivacyModeNotification
component: <HomeNotification ? <HomeNotification
descriptionText={t('privacyModeDefault')} descriptionText={t('privacyModeDefault')}
acceptText={t('learnMore')} acceptText={t('learnMore')}
onAccept={() => { onAccept={() => {
@ -134,11 +134,12 @@ export default class Home extends PureComponent {
unsetMigratedPrivacyMode() unsetMigratedPrivacyMode()
}} }}
key="home-privacyModeDefault" key="home-privacyModeDefault"
/>, />
}, : null
}
{ {
shouldBeRendered: shouldShowSeedPhraseReminder, shouldShowSeedPhraseReminder
component: <HomeNotification ? <HomeNotification
descriptionText={t('backupApprovalNotice')} descriptionText={t('backupApprovalNotice')}
acceptText={t('backupNow')} acceptText={t('backupNow')}
onAccept={() => { onAccept={() => {
@ -150,12 +151,13 @@ export default class Home extends PureComponent {
}} }}
infoText={t('backupApprovalInfo')} infoText={t('backupApprovalInfo')}
key="home-backupApprovalNotice" key="home-backupApprovalNotice"
/>, />
}, : null
}
{ {
shouldBeRendered: threeBoxLastUpdated && showRestorePrompt, threeBoxLastUpdated && showRestorePrompt
component: <HomeNotification ? <HomeNotification
descriptionText={t('restoreWalletPreferences', [ formatDate(parseInt(threeBoxLastUpdated), 'M/d/y') ])} descriptionText={t('restoreWalletPreferences', [ formatDate(threeBoxLastUpdated, 'M/d/y') ])}
acceptText={t('restore')} acceptText={t('restore')}
ignoreText={t('noThanks')} ignoreText={t('noThanks')}
infoText={t('dataBackupFoundInfo')} infoText={t('dataBackupFoundInfo')}
@ -169,9 +171,10 @@ export default class Home extends PureComponent {
setShowRestorePromptToFalse() setShowRestorePromptToFalse()
}} }}
key="home-privacyModeDefault" key="home-privacyModeDefault"
/>, />
}, : null
]}/> }
</MultipleNotifications>
</TransactionView> </TransactionView>
) )
: null } : null }

Loading…
Cancel
Save