import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { inject, observer } from 'mobx-react'; import { defineMessages, intlShape } from 'react-intl'; import injectSheet from 'react-jss'; import Button from '../../components/ui/Button'; import { config } from '.'; import styles from './styles'; const messages = defineMessages({ headline: { id: 'feature.delayApp.headline', defaultMessage: '!!!Please purchase license to skip waiting', }, action: { id: 'feature.delayApp.action', defaultMessage: '!!!Get a Franz Supporter License', }, text: { id: 'feature.delayApp.text', defaultMessage: '!!!Franz will continue in {seconds} seconds.', }, }); export default @inject('actions') @injectSheet(styles) @observer class DelayApp extends Component { static propTypes = { // eslint-disable-next-line classes: PropTypes.object.isRequired, }; static contextTypes = { intl: intlShape, }; state = { countdown: config.delayDuration, } countdownInterval = null; countdownIntervalTimeout = 1000; componentDidMount() { this.countdownInterval = setInterval(() => { this.setState({ countdown: prevState => ({ value: prevState.countdown - this.countdownIntervalTimeout }), }); if (this.state.countdown <= 0) { // reload(); clearInterval(this.countdownInterval); } }, this.countdownIntervalTimeout); } componentWillUnmount() { clearInterval(this.countdownInterval); } render() { const { classes, actions } = this.props; const { intl } = this.context; return (