diff options
author | vantezzen <properly@protonmail.com> | 2019-09-07 15:50:23 +0200 |
---|---|---|
committer | vantezzen <properly@protonmail.com> | 2019-09-07 15:50:23 +0200 |
commit | e7a74514c1e7c3833dfdcf5900cb87f9e6e8354e (patch) | |
tree | b8314e4155503b135dcb07e8b4a0e847e25c19cf /src/features/delayApp | |
parent | Update CHANGELOG.md (diff) | |
parent | Update CHANGELOG.md (diff) | |
download | ferdium-app-e7a74514c1e7c3833dfdcf5900cb87f9e6e8354e.tar.gz ferdium-app-e7a74514c1e7c3833dfdcf5900cb87f9e6e8354e.tar.zst ferdium-app-e7a74514c1e7c3833dfdcf5900cb87f9e6e8354e.zip |
Merge branch 'master' of https://github.com/meetfranz/franz into franz-5.3.0
Diffstat (limited to 'src/features/delayApp')
-rw-r--r-- | src/features/delayApp/Component.js | 41 | ||||
-rw-r--r-- | src/features/delayApp/index.js | 10 |
2 files changed, 38 insertions, 13 deletions
diff --git a/src/features/delayApp/Component.js b/src/features/delayApp/Component.js index ba50652e8..c61cb06c9 100644 --- a/src/features/delayApp/Component.js +++ b/src/features/delayApp/Component.js | |||
@@ -4,19 +4,28 @@ import { inject, observer } from 'mobx-react'; | |||
4 | import { defineMessages, intlShape } from 'react-intl'; | 4 | import { defineMessages, intlShape } from 'react-intl'; |
5 | import injectSheet from 'react-jss'; | 5 | import injectSheet from 'react-jss'; |
6 | 6 | ||
7 | import Button from '../../components/ui/Button'; | 7 | import { Button } from '@meetfranz/forms'; |
8 | 8 | ||
9 | import { config } from '.'; | 9 | import { config } from '.'; |
10 | import styles from './styles'; | 10 | import styles from './styles'; |
11 | import UserStore from '../../stores/UserStore'; | ||
11 | 12 | ||
12 | const messages = defineMessages({ | 13 | const messages = defineMessages({ |
13 | headline: { | 14 | headline: { |
14 | id: 'feature.delayApp.headline', | 15 | id: 'feature.delayApp.headline', |
15 | defaultMessage: '!!!Please purchase license to skip waiting', | 16 | defaultMessage: '!!!Please purchase license to skip waiting', |
16 | }, | 17 | }, |
18 | headlineTrial: { | ||
19 | id: 'feature.delayApp.trial.headline', | ||
20 | defaultMessage: '!!!Get the free Franz Professional 14 day trial and skip the line', | ||
21 | }, | ||
17 | action: { | 22 | action: { |
18 | id: 'feature.delayApp.action', | 23 | id: 'feature.delayApp.upgrade.action', |
19 | defaultMessage: '!!!Get a Ferdi Supporter License', | 24 | defaultMessage: '!!!Get a Franz Supporter License', |
25 | }, | ||
26 | actionTrial: { | ||
27 | id: 'feature.delayApp.trial.action', | ||
28 | defaultMessage: '!!!Yes, I want the free 14 day trial of Franz Professional', | ||
20 | }, | 29 | }, |
21 | text: { | 30 | text: { |
22 | id: 'feature.delayApp.text', | 31 | id: 'feature.delayApp.text', |
@@ -24,7 +33,7 @@ const messages = defineMessages({ | |||
24 | }, | 33 | }, |
25 | }); | 34 | }); |
26 | 35 | ||
27 | export default @inject('actions') @injectSheet(styles) @observer class DelayApp extends Component { | 36 | export default @inject('stores', 'actions') @injectSheet(styles) @observer class DelayApp extends Component { |
28 | static propTypes = { | 37 | static propTypes = { |
29 | // eslint-disable-next-line | 38 | // eslint-disable-next-line |
30 | classes: PropTypes.object.isRequired, | 39 | classes: PropTypes.object.isRequired, |
@@ -60,23 +69,32 @@ export default @inject('actions') @injectSheet(styles) @observer class DelayApp | |||
60 | } | 69 | } |
61 | 70 | ||
62 | handleCTAClick() { | 71 | handleCTAClick() { |
63 | const { actions } = this.props; | 72 | const { actions, stores } = this.props; |
64 | 73 | const { hadSubscription } = stores.user.data; | |
65 | actions.ui.openSettings({ path: 'user' }); | 74 | const { defaultTrialPlan } = stores.features.features; |
75 | |||
76 | if (!hadSubscription) { | ||
77 | actions.user.activateTrial({ planId: defaultTrialPlan }); | ||
78 | } else { | ||
79 | actions.ui.openSettings({ path: 'user' }); | ||
80 | } | ||
66 | } | 81 | } |
67 | 82 | ||
68 | render() { | 83 | render() { |
69 | const { classes } = this.props; | 84 | const { classes, stores } = this.props; |
70 | const { intl } = this.context; | 85 | const { intl } = this.context; |
71 | 86 | ||
87 | const { hadSubscription } = stores.user.data; | ||
88 | |||
72 | return ( | 89 | return ( |
73 | <div className={`${classes.container}`}> | 90 | <div className={`${classes.container}`}> |
74 | <h1 className={classes.headline}>{intl.formatMessage(messages.headline)}</h1> | 91 | <h1 className={classes.headline}>{intl.formatMessage(hadSubscription ? messages.headline : messages.headlineTrial)}</h1> |
75 | <Button | 92 | <Button |
76 | label={intl.formatMessage(messages.action)} | 93 | label={intl.formatMessage(hadSubscription ? messages.action : messages.actionTrial)} |
77 | className={classes.button} | 94 | className={classes.button} |
78 | buttonType="inverted" | 95 | buttonType="inverted" |
79 | onClick={this.handleCTAClick.bind(this)} | 96 | onClick={this.handleCTAClick.bind(this)} |
97 | busy={stores.user.activateTrialRequest.isExecuting} | ||
80 | /> | 98 | /> |
81 | <p className="footnote"> | 99 | <p className="footnote"> |
82 | {intl.formatMessage(messages.text, { | 100 | {intl.formatMessage(messages.text, { |
@@ -89,6 +107,9 @@ export default @inject('actions') @injectSheet(styles) @observer class DelayApp | |||
89 | } | 107 | } |
90 | 108 | ||
91 | DelayApp.wrappedComponent.propTypes = { | 109 | DelayApp.wrappedComponent.propTypes = { |
110 | stores: PropTypes.shape({ | ||
111 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
112 | }).isRequired, | ||
92 | actions: PropTypes.shape({ | 113 | actions: PropTypes.shape({ |
93 | ui: PropTypes.shape({ | 114 | ui: PropTypes.shape({ |
94 | openSettings: PropTypes.func.isRequired, | 115 | openSettings: PropTypes.func.isRequired, |
diff --git a/src/features/delayApp/index.js b/src/features/delayApp/index.js index c753eeffe..4f793f16c 100644 --- a/src/features/delayApp/index.js +++ b/src/features/delayApp/index.js | |||
@@ -43,14 +43,16 @@ export default function init(stores) { | |||
43 | config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait; | 43 | config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait; |
44 | 44 | ||
45 | autorun(() => { | 45 | autorun(() => { |
46 | if (stores.services.all.length === 0) { | 46 | const { isAnnouncementShown } = stores.announcements; |
47 | debug('seas', stores.services.all.length); | 47 | if (stores.services.allDisplayed.length === 0 || isAnnouncementShown) { |
48 | shownAfterLaunch = true; | 48 | shownAfterLaunch = true; |
49 | setVisibility(false); | ||
49 | return; | 50 | return; |
50 | } | 51 | } |
51 | 52 | ||
52 | const diff = moment().diff(timeLastDelay); | 53 | const diff = moment().diff(timeLastDelay); |
53 | if ((stores.app.isFocused && diff >= config.delayOffset) || !shownAfterLaunch) { | 54 | const itsTimeToWait = diff >= config.delayOffset; |
55 | if (!isAnnouncementShown && ((stores.app.isFocused && itsTimeToWait) || !shownAfterLaunch)) { | ||
54 | debug(`App will be delayed for ${config.delayDuration / 1000}s`); | 56 | debug(`App will be delayed for ${config.delayDuration / 1000}s`); |
55 | 57 | ||
56 | setVisibility(true); | 58 | setVisibility(true); |
@@ -63,6 +65,8 @@ export default function init(stores) { | |||
63 | 65 | ||
64 | setVisibility(false); | 66 | setVisibility(false); |
65 | }, config.delayDuration + 1000); // timer needs to be able to hit 0 | 67 | }, config.delayDuration + 1000); // timer needs to be able to hit 0 |
68 | } else { | ||
69 | setVisibility(false); | ||
66 | } | 70 | } |
67 | }); | 71 | }); |
68 | } else { | 72 | } else { |