From df4d195ec7135c76f8f5de54c3939d2e74e80d4a Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Sat, 24 Nov 2018 20:20:31 +0100 Subject: Delay app based on featureAPI settings --- src/features/delayApp/Component.js | 86 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 src/features/delayApp/Component.js (limited to 'src/features/delayApp/Component.js') diff --git a/src/features/delayApp/Component.js b/src/features/delayApp/Component.js new file mode 100644 index 000000000..2bfa1162e --- /dev/null +++ b/src/features/delayApp/Component.js @@ -0,0 +1,86 @@ +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') @observer @injectSheet(styles) class DelayApp extends Component { + static propTypes = { + // eslint-disable-next-line + classes: PropTypes.object.isRequired, + }; + + static contextTypes = { + intl: intlShape, + }; + + state = { + countdown: config.delayDuration, + } + + componentDidMount() { + // const { reload } = this.props; + + this.countdownInterval = setInterval(() => { + this.setState({ + countdown: this.state.countdown - this.countdownIntervalTimeout, + }); + + if (this.state.countdown <= 0) { + // reload(); + clearInterval(this.countdownInterval); + } + }, this.countdownIntervalTimeout); + } + + countdownInterval = null; + countdownIntervalTimeout = 1000; + + render() { + const { classes, actions } = this.props; + const { intl } = this.context; + + return ( +
+

{intl.formatMessage(messages.headline)}

+
+ ); + } +} + +DelayApp.wrappedComponent.propTypes = { + actions: PropTypes.shape({ + ui: PropTypes.shape({ + openSettings: PropTypes.func.isRequired, + }).isRequired, + }).isRequired, +}; -- cgit v1.2.3-70-g09d2