diff options
author | Stefan Malzner <stefan@adlk.io> | 2019-10-16 15:16:26 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2019-10-16 15:16:26 +0200 |
commit | 0b08e1e7e6a07acd21af71fd27f4c4acfa34dbba (patch) | |
tree | 9ee5b287f3c0451012153cf281659159597d63e7 /src/stores | |
parent | polishing (diff) | |
download | ferdium-app-0b08e1e7e6a07acd21af71fd27f4c4acfa34dbba.tar.gz ferdium-app-0b08e1e7e6a07acd21af71fd27f4c4acfa34dbba.tar.zst ferdium-app-0b08e1e7e6a07acd21af71fd27f4c4acfa34dbba.zip |
Add trialStatusBar & polishing
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/AppStore.js | 14 | ||||
-rw-r--r-- | src/stores/FeaturesStore.js | 2 | ||||
-rw-r--r-- | src/stores/PaymentStore.js | 37 | ||||
-rw-r--r-- | src/stores/UserStore.js | 4 |
4 files changed, 56 insertions, 1 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index f102fc370..329c43f32 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -81,6 +81,8 @@ export default class AppStore extends Store { | |||
81 | 81 | ||
82 | dictionaries = []; | 82 | dictionaries = []; |
83 | 83 | ||
84 | fetchDataInterval = null; | ||
85 | |||
84 | constructor(...args) { | 86 | constructor(...args) { |
85 | super(...args); | 87 | super(...args); |
86 | 88 | ||
@@ -102,6 +104,7 @@ export default class AppStore extends Store { | |||
102 | this._setLocale.bind(this), | 104 | this._setLocale.bind(this), |
103 | this._muteAppHandler.bind(this), | 105 | this._muteAppHandler.bind(this), |
104 | this._handleFullScreen.bind(this), | 106 | this._handleFullScreen.bind(this), |
107 | this._handleLogout.bind(this), | ||
105 | ]); | 108 | ]); |
106 | } | 109 | } |
107 | 110 | ||
@@ -129,6 +132,11 @@ export default class AppStore extends Store { | |||
129 | this._systemDND(); | 132 | this._systemDND(); |
130 | setInterval(() => this._systemDND(), ms('5s')); | 133 | setInterval(() => this._systemDND(), ms('5s')); |
131 | 134 | ||
135 | this.fetchDataInterval = setInterval(() => { | ||
136 | this.stores.user.getUserInfoRequest.invalidate({ immediately: true }); | ||
137 | this.stores.features.featuresRequest.invalidate({ immediately: true }); | ||
138 | }, ms('10s')); | ||
139 | |||
132 | // Check for updates once every 4 hours | 140 | // Check for updates once every 4 hours |
133 | setInterval(() => this._checkForUpdates(), CHECK_INTERVAL); | 141 | setInterval(() => this._checkForUpdates(), CHECK_INTERVAL); |
134 | // Check for an update in 30s (need a delay to prevent Squirrel Installer lock file issues) | 142 | // Check for an update in 30s (need a delay to prevent Squirrel Installer lock file issues) |
@@ -430,6 +438,12 @@ export default class AppStore extends Store { | |||
430 | } | 438 | } |
431 | } | 439 | } |
432 | 440 | ||
441 | _handleLogout() { | ||
442 | if (!this.stores.user.isLoggedIn) { | ||
443 | clearInterval(this.fetchDataInterval); | ||
444 | } | ||
445 | } | ||
446 | |||
433 | // Helpers | 447 | // Helpers |
434 | _appStartsCounter() { | 448 | _appStartsCounter() { |
435 | this.actions.settings.update({ | 449 | this.actions.settings.update({ |
diff --git a/src/stores/FeaturesStore.js b/src/stores/FeaturesStore.js index bffcb01bc..5d379fd3e 100644 --- a/src/stores/FeaturesStore.js +++ b/src/stores/FeaturesStore.js | |||
@@ -20,6 +20,7 @@ import serviceLimit from '../features/serviceLimit'; | |||
20 | import communityRecipes from '../features/communityRecipes'; | 20 | import communityRecipes from '../features/communityRecipes'; |
21 | import todos from '../features/todos'; | 21 | import todos from '../features/todos'; |
22 | import planSelection from '../features/planSelection'; | 22 | import planSelection from '../features/planSelection'; |
23 | import trialStatusBar from '../features/trialStatusBar'; | ||
23 | 24 | ||
24 | import { DEFAULT_FEATURES_CONFIG } from '../config'; | 25 | import { DEFAULT_FEATURES_CONFIG } from '../config'; |
25 | 26 | ||
@@ -83,5 +84,6 @@ export default class FeaturesStore extends Store { | |||
83 | communityRecipes(this.stores, this.actions); | 84 | communityRecipes(this.stores, this.actions); |
84 | todos(this.stores, this.actions); | 85 | todos(this.stores, this.actions); |
85 | planSelection(this.stores, this.actions); | 86 | planSelection(this.stores, this.actions); |
87 | trialStatusBar(this.stores, this.actions); | ||
86 | } | 88 | } |
87 | } | 89 | } |
diff --git a/src/stores/PaymentStore.js b/src/stores/PaymentStore.js index d4de476c8..b90e8f006 100644 --- a/src/stores/PaymentStore.js +++ b/src/stores/PaymentStore.js | |||
@@ -1,10 +1,13 @@ | |||
1 | import { action, observable, computed } from 'mobx'; | 1 | import { action, observable, computed } from 'mobx'; |
2 | import { remote } from 'electron'; | ||
2 | 3 | ||
3 | import Store from './lib/Store'; | 4 | import Store from './lib/Store'; |
4 | import CachedRequest from './lib/CachedRequest'; | 5 | import CachedRequest from './lib/CachedRequest'; |
5 | import Request from './lib/Request'; | 6 | import Request from './lib/Request'; |
6 | import { gaEvent } from '../lib/analytics'; | 7 | import { gaEvent } from '../lib/analytics'; |
7 | 8 | ||
9 | const { BrowserWindow } = remote; | ||
10 | |||
8 | export default class PaymentStore extends Store { | 11 | export default class PaymentStore extends Store { |
9 | @observable plansRequest = new CachedRequest(this.api.payment, 'plans'); | 12 | @observable plansRequest = new CachedRequest(this.api.payment, 'plans'); |
10 | 13 | ||
@@ -14,6 +17,7 @@ export default class PaymentStore extends Store { | |||
14 | super(...args); | 17 | super(...args); |
15 | 18 | ||
16 | this.actions.payment.createHostedPage.listen(this._createHostedPage.bind(this)); | 19 | this.actions.payment.createHostedPage.listen(this._createHostedPage.bind(this)); |
20 | this.actions.payment.upgradeAccount.listen(this._upgradeAccount.bind(this)); | ||
17 | } | 21 | } |
18 | 22 | ||
19 | @computed get plan() { | 23 | @computed get plan() { |
@@ -30,4 +34,37 @@ export default class PaymentStore extends Store { | |||
30 | 34 | ||
31 | return request; | 35 | return request; |
32 | } | 36 | } |
37 | |||
38 | @action _upgradeAccount({ planId, onCloseWindow = () => null }) { | ||
39 | let hostedPageURL = this.stores.features.features.subscribeURL; | ||
40 | |||
41 | const parsedUrl = new URL(hostedPageURL); | ||
42 | const params = new URLSearchParams(parsedUrl.search.slice(1)); | ||
43 | |||
44 | params.set('plan', planId); | ||
45 | |||
46 | hostedPageURL = this.stores.user.getAuthURL(`${parsedUrl.origin}${parsedUrl.pathname}?${params.toString()}`); | ||
47 | |||
48 | const win = new BrowserWindow({ | ||
49 | parent: remote.getCurrentWindow(), | ||
50 | modal: true, | ||
51 | title: '🔒 Upgrade Your Franz Account', | ||
52 | width: 800, | ||
53 | height: window.innerHeight - 100, | ||
54 | maxWidth: 800, | ||
55 | minWidth: 600, | ||
56 | webPreferences: { | ||
57 | nodeIntegration: true, | ||
58 | webviewTag: true, | ||
59 | }, | ||
60 | }); | ||
61 | win.loadURL(`file://${__dirname}/../index.html#/payment/${encodeURIComponent(hostedPageURL)}`); | ||
62 | |||
63 | win.on('closed', () => { | ||
64 | this.stores.user.getUserInfoRequest.invalidate({ immediately: true }); | ||
65 | this.stores.features.featuresRequest.invalidate({ immediately: true }); | ||
66 | |||
67 | onCloseWindow(); | ||
68 | }); | ||
69 | } | ||
33 | } | 70 | } |
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index b652098f9..735e8f886 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js | |||
@@ -77,6 +77,8 @@ export default class UserStore extends Store { | |||
77 | 77 | ||
78 | @observable logoutReason = null; | 78 | @observable logoutReason = null; |
79 | 79 | ||
80 | fetchUserInfoInterval = null; | ||
81 | |||
80 | constructor(...args) { | 82 | constructor(...args) { |
81 | super(...args); | 83 | super(...args); |
82 | 84 | ||
@@ -161,7 +163,7 @@ export default class UserStore extends Store { | |||
161 | } | 163 | } |
162 | 164 | ||
163 | @computed get isPremiumOverride() { | 165 | @computed get isPremiumOverride() { |
164 | return ((!this.team || !this.team.plan) && this.isPremium) || (this.team.state === 'expired' && this.isPremium); | 166 | return ((!this.team || !this.team.plan) && this.isPremium) || (this.team && this.team.state === 'expired' && this.isPremium); |
165 | } | 167 | } |
166 | 168 | ||
167 | @computed get isPersonal() { | 169 | @computed get isPersonal() { |