diff options
author | 2021-08-13 00:45:01 +0530 | |
---|---|---|
committer | 2021-08-13 00:45:01 +0530 | |
commit | 2d27d5e66649d4f5baf127a53ee5ae524eae3a59 (patch) | |
tree | c592ea219ac8cd987fc367f57b54034c450ab2ab /src/stores/UserStore.js | |
parent | Ferdi v5.6.0 (diff) | |
parent | 5.6.1-nightly.24 [skip ci] (diff) | |
download | ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.gz ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.tar.zst ferdium-app-2d27d5e66649d4f5baf127a53ee5ae524eae3a59.zip |
chore: merge from nightly branch into release branch in prep for next beta
Diffstat (limited to 'src/stores/UserStore.js')
-rw-r--r-- | src/stores/UserStore.js | 69 |
1 files changed, 3 insertions, 66 deletions
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 7947e5a27..2e009893a 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js | |||
@@ -2,16 +2,13 @@ import { observable, computed, action } from 'mobx'; | |||
2 | import moment from 'moment'; | 2 | import moment from 'moment'; |
3 | import jwt from 'jsonwebtoken'; | 3 | import jwt from 'jsonwebtoken'; |
4 | import localStorage from 'mobx-localstorage'; | 4 | import localStorage from 'mobx-localstorage'; |
5 | import ms from 'ms'; | ||
6 | import { session } from '@electron/remote'; | 5 | import { session } from '@electron/remote'; |
7 | 6 | ||
8 | import { isDevMode } from '../environment'; | 7 | import { isDevMode } from '../environment'; |
9 | import Store from './lib/Store'; | 8 | import Store from './lib/Store'; |
10 | import Request from './lib/Request'; | 9 | import Request from './lib/Request'; |
11 | import CachedRequest from './lib/CachedRequest'; | 10 | import CachedRequest from './lib/CachedRequest'; |
12 | import { sleep } from '../helpers/async-helpers'; | 11 | import { TODOS_PARTITION_ID } from '../config'; |
13 | import { getPlan } from '../helpers/plan-helpers'; | ||
14 | import { PLANS, TODOS_PARTITION_ID } from '../config'; | ||
15 | 12 | ||
16 | const debug = require('debug')('Ferdi:UserStore'); | 13 | const debug = require('debug')('Ferdi:UserStore'); |
17 | 14 | ||
@@ -27,8 +24,6 @@ export default class UserStore extends Store { | |||
27 | 24 | ||
28 | SIGNUP_ROUTE = `${this.BASE_ROUTE}/signup`; | 25 | SIGNUP_ROUTE = `${this.BASE_ROUTE}/signup`; |
29 | 26 | ||
30 | PRICING_ROUTE = `${this.BASE_ROUTE}/signup/pricing`; | ||
31 | |||
32 | SETUP_ROUTE = `${this.BASE_ROUTE}/signup/setup`; | 27 | SETUP_ROUTE = `${this.BASE_ROUTE}/signup/setup`; |
33 | 28 | ||
34 | IMPORT_ROUTE = `${this.BASE_ROUTE}/signup/import`; | 29 | IMPORT_ROUTE = `${this.BASE_ROUTE}/signup/import`; |
@@ -45,8 +40,6 @@ export default class UserStore extends Store { | |||
45 | 40 | ||
46 | @observable passwordRequest = new Request(this.api.user, 'password'); | 41 | @observable passwordRequest = new Request(this.api.user, 'password'); |
47 | 42 | ||
48 | @observable activateTrialRequest = new Request(this.api.user, 'activateTrial'); | ||
49 | |||
50 | @observable inviteRequest = new Request(this.api.user, 'invite'); | 43 | @observable inviteRequest = new Request(this.api.user, 'invite'); |
51 | 44 | ||
52 | @observable getUserInfoRequest = new CachedRequest(this.api.user, 'getInfo'); | 45 | @observable getUserInfoRequest = new CachedRequest(this.api.user, 'getInfo'); |
@@ -71,8 +64,6 @@ export default class UserStore extends Store { | |||
71 | 64 | ||
72 | @observable hasCompletedSignup = false; | 65 | @observable hasCompletedSignup = false; |
73 | 66 | ||
74 | @observable hasActivatedTrial = false; | ||
75 | |||
76 | @observable userData = {}; | 67 | @observable userData = {}; |
77 | 68 | ||
78 | @observable actionStatus = []; | 69 | @observable actionStatus = []; |
@@ -93,7 +84,6 @@ export default class UserStore extends Store { | |||
93 | this.actions.user.retrievePassword.listen(this._retrievePassword.bind(this)); | 84 | this.actions.user.retrievePassword.listen(this._retrievePassword.bind(this)); |
94 | this.actions.user.logout.listen(this._logout.bind(this)); | 85 | this.actions.user.logout.listen(this._logout.bind(this)); |
95 | this.actions.user.signup.listen(this._signup.bind(this)); | 86 | this.actions.user.signup.listen(this._signup.bind(this)); |
96 | this.actions.user.activateTrial.listen(this._activateTrial.bind(this)); | ||
97 | this.actions.user.invite.listen(this._invite.bind(this)); | 87 | this.actions.user.invite.listen(this._invite.bind(this)); |
98 | this.actions.user.update.listen(this._update.bind(this)); | 88 | this.actions.user.update.listen(this._update.bind(this)); |
99 | this.actions.user.resetStatus.listen(this._resetStatus.bind(this)); | 89 | this.actions.user.resetStatus.listen(this._resetStatus.bind(this)); |
@@ -104,7 +94,6 @@ export default class UserStore extends Store { | |||
104 | this.registerReactions([ | 94 | this.registerReactions([ |
105 | this._requireAuthenticatedUser.bind(this), | 95 | this._requireAuthenticatedUser.bind(this), |
106 | this._getUserData.bind(this), | 96 | this._getUserData.bind(this), |
107 | this._resetTrialActivationState.bind(this), | ||
108 | ]); | 97 | ]); |
109 | } | 98 | } |
110 | 99 | ||
@@ -126,10 +115,6 @@ export default class UserStore extends Store { | |||
126 | return this.SIGNUP_ROUTE; | 115 | return this.SIGNUP_ROUTE; |
127 | } | 116 | } |
128 | 117 | ||
129 | get pricingRoute() { | ||
130 | return this.PRICING_ROUTE; | ||
131 | } | ||
132 | |||
133 | get setupRoute() { | 118 | get setupRoute() { |
134 | return this.SETUP_ROUTE; | 119 | return this.SETUP_ROUTE; |
135 | } | 120 | } |
@@ -172,31 +157,6 @@ export default class UserStore extends Store { | |||
172 | return this.data.team || null; | 157 | return this.data.team || null; |
173 | } | 158 | } |
174 | 159 | ||
175 | @computed get isPremium() { | ||
176 | return true; | ||
177 | } | ||
178 | |||
179 | @computed get isPremiumOverride() { | ||
180 | return ((!this.team || !this.team.plan) && this.isPremium) || (this.team && this.team.state === 'expired' && this.isPremium); | ||
181 | } | ||
182 | |||
183 | @computed get isPersonal() { | ||
184 | if (!this.team || !this.team.plan) return false; | ||
185 | const plan = getPlan(this.team.plan); | ||
186 | |||
187 | return plan === PLANS.PERSONAL; | ||
188 | } | ||
189 | |||
190 | @computed get isPro() { | ||
191 | return true; | ||
192 | // if (this.isPremiumOverride) return true; | ||
193 | |||
194 | // if (!this.team || (!this.team.plan || this.team.state === 'expired')) return false; | ||
195 | // const plan = getPlan(this.team.plan); | ||
196 | |||
197 | // return plan === PLANS.PRO || plan === PLANS.LEGACY; | ||
198 | } | ||
199 | |||
200 | @computed get legacyServices() { | 160 | @computed get legacyServices() { |
201 | return this.getLegacyServicesRequest.execute() || {}; | 161 | return this.getLegacyServicesRequest.execute() || {}; |
202 | } | 162 | } |
@@ -244,23 +204,8 @@ export default class UserStore extends Store { | |||
244 | this.actionStatus = request.result.status || []; | 204 | this.actionStatus = request.result.status || []; |
245 | } | 205 | } |
246 | 206 | ||
247 | @action async _activateTrial({ planId }) { | ||
248 | debug('activate trial', planId); | ||
249 | |||
250 | this.activateTrialRequest.execute({ | ||
251 | plan: planId, | ||
252 | }); | ||
253 | |||
254 | await this.activateTrialRequest._promise; | ||
255 | |||
256 | this.hasActivatedTrial = true; | ||
257 | |||
258 | this.stores.features.featuresRequest.invalidate({ immediately: true }); | ||
259 | this.stores.user.getUserInfoRequest.invalidate({ immediately: true }); | ||
260 | } | ||
261 | |||
262 | @action async _invite({ invites }) { | 207 | @action async _invite({ invites }) { |
263 | const data = invites.filter(invite => invite.email !== ''); | 208 | const data = invites.filter((invite) => invite.email !== ''); |
264 | 209 | ||
265 | const response = await this.inviteRequest.execute(data)._promise; | 210 | const response = await this.inviteRequest.execute(data)._promise; |
266 | 211 | ||
@@ -305,7 +250,7 @@ export default class UserStore extends Store { | |||
305 | this.isImportLegacyServicesExecuting = true; | 250 | this.isImportLegacyServicesExecuting = true; |
306 | 251 | ||
307 | // Reduces recipe duplicates | 252 | // Reduces recipe duplicates |
308 | const recipes = services.filter((obj, pos, arr) => arr.map(mapObj => mapObj.recipe.id).indexOf(obj.recipe.id) === pos).map(s => s.recipe.id); | 253 | const recipes = services.filter((obj, pos, arr) => arr.map((mapObj) => mapObj.recipe.id).indexOf(obj.recipe.id) === pos).map((s) => s.recipe.id); |
309 | 254 | ||
310 | // Install recipes | 255 | // Install recipes |
311 | for (const recipe of recipes) { // eslint-disable-line no-unused-vars | 256 | for (const recipe of recipes) { // eslint-disable-line no-unused-vars |
@@ -386,14 +331,6 @@ export default class UserStore extends Store { | |||
386 | } | 331 | } |
387 | } | 332 | } |
388 | 333 | ||
389 | async _resetTrialActivationState() { | ||
390 | if (this.hasActivatedTrial) { | ||
391 | await sleep(ms('12s')); | ||
392 | |||
393 | this.hasActivatedTrial = false; | ||
394 | } | ||
395 | } | ||
396 | |||
397 | // Helpers | 334 | // Helpers |
398 | _parseToken(authToken) { | 335 | _parseToken(authToken) { |
399 | try { | 336 | try { |