aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/delayApp
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2019-02-12 13:26:50 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2019-02-12 13:26:50 +0100
commit3d2b58b387ce8b22cd7b674445d56d81019ef16c (patch)
tree7bf922ae2932ca9467246fca7288a49deb29ea9b /src/features/delayApp
parentAdd withTheme context to button (diff)
parentFix windows token login (diff)
downloadferdium-app-3d2b58b387ce8b22cd7b674445d56d81019ef16c.tar.gz
ferdium-app-3d2b58b387ce8b22cd7b674445d56d81019ef16c.tar.zst
ferdium-app-3d2b58b387ce8b22cd7b674445d56d81019ef16c.zip
Merge branch 'develop' into chore/lerna
Diffstat (limited to 'src/features/delayApp')
-rw-r--r--src/features/delayApp/Component.js14
-rw-r--r--src/features/delayApp/index.js23
2 files changed, 25 insertions, 12 deletions
diff --git a/src/features/delayApp/Component.js b/src/features/delayApp/Component.js
index 6e0532c9a..ff84510e8 100644
--- a/src/features/delayApp/Component.js
+++ b/src/features/delayApp/Component.js
@@ -4,6 +4,8 @@ import { inject, observer } from 'mobx-react';
4import { defineMessages, intlShape } from 'react-intl'; 4import { defineMessages, intlShape } from 'react-intl';
5import injectSheet from 'react-jss'; 5import injectSheet from 'react-jss';
6 6
7import { gaEvent } from '../../lib/analytics';
8
7import Button from '../../components/ui/Button'; 9import Button from '../../components/ui/Button';
8 10
9import { config } from '.'; 11import { config } from '.';
@@ -59,8 +61,16 @@ export default @inject('actions') @injectSheet(styles) @observer class DelayApp
59 clearInterval(this.countdownInterval); 61 clearInterval(this.countdownInterval);
60 } 62 }
61 63
64 handleCTAClick() {
65 const { actions } = this.props;
66
67 actions.ui.openSettings({ path: 'user' });
68
69 gaEvent('DelayApp', 'subscribe_click', 'Delay App Feature');
70 }
71
62 render() { 72 render() {
63 const { classes, actions } = this.props; 73 const { classes } = this.props;
64 const { intl } = this.context; 74 const { intl } = this.context;
65 75
66 return ( 76 return (
@@ -70,7 +80,7 @@ export default @inject('actions') @injectSheet(styles) @observer class DelayApp
70 label={intl.formatMessage(messages.action)} 80 label={intl.formatMessage(messages.action)}
71 className={classes.button} 81 className={classes.button}
72 buttonType="inverted" 82 buttonType="inverted"
73 onClick={() => actions.ui.openSettings({ path: 'user' })} 83 onClick={this.handleCTAClick.bind(this)}
74 /> 84 />
75 <p className="footnote"> 85 <p className="footnote">
76 {intl.formatMessage(messages.text, { 86 {intl.formatMessage(messages.text, {
diff --git a/src/features/delayApp/index.js b/src/features/delayApp/index.js
index d5c544b78..28aa50eb2 100644
--- a/src/features/delayApp/index.js
+++ b/src/features/delayApp/index.js
@@ -3,6 +3,7 @@ import moment from 'moment';
3import DelayAppComponent from './Component'; 3import DelayAppComponent from './Component';
4 4
5import { DEFAULT_FEATURES_CONFIG } from '../../config'; 5import { DEFAULT_FEATURES_CONFIG } from '../../config';
6import { gaEvent } from '../../lib/analytics';
6 7
7const debug = require('debug')('Franz:feature:delayApp'); 8const debug = require('debug')('Franz:feature:delayApp');
8 9
@@ -22,19 +23,18 @@ function setVisibility(value) {
22} 23}
23 24
24export default function init(stores) { 25export default function init(stores) {
25 reaction( 26 debug('Initializing `delayApp` feature');
26 () => stores.features.features.needToWaitToProceed,
27 (enabled, r) => {
28 if (enabled) {
29 debug('Initializing `delayApp` feature');
30 27
31 // Dispose the reaction to run this only once 28 let shownAfterLaunch = false;
32 r.dispose(); 29 let timeLastDelay = moment();
33 30
34 const { needToWaitToProceedConfig: globalConfig } = stores.features.features; 31 reaction(
32 () => stores.features.features.needToWaitToProceed && !stores.user.data.isPremium,
33 (isEnabled) => {
34 if (isEnabled) {
35 debug('Enabling `delayApp` feature');
35 36
36 let shownAfterLaunch = false; 37 const { needToWaitToProceedConfig: globalConfig } = stores.features.features;
37 let timeLastDelay = moment();
38 38
39 config.delayOffset = globalConfig.delayOffset !== undefined ? globalConfig.delayOffset : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.delayOffset; 39 config.delayOffset = globalConfig.delayOffset !== undefined ? globalConfig.delayOffset : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.delayOffset;
40 config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait; 40 config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait;
@@ -50,6 +50,7 @@ export default function init(stores) {
50 debug(`App will be delayed for ${config.delayDuration / 1000}s`); 50 debug(`App will be delayed for ${config.delayDuration / 1000}s`);
51 51
52 setVisibility(true); 52 setVisibility(true);
53 gaEvent('delayApp', 'show', 'Delay App Feature');
53 54
54 timeLastDelay = moment(); 55 timeLastDelay = moment();
55 shownAfterLaunch = true; 56 shownAfterLaunch = true;
@@ -61,6 +62,8 @@ export default function init(stores) {
61 }, DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait + 1000); // timer needs to be able to hit 0 62 }, DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait + 1000); // timer needs to be able to hit 0
62 } 63 }
63 }); 64 });
65 } else {
66 setVisibility(false);
64 } 67 }
65 }, 68 },
66 ); 69 );