aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2019-08-05 13:24:35 +0200
committerLibravatar Stefan Malzner <stefan@adlk.io>2019-08-05 13:24:35 +0200
commit76559f2895012803aed3256ce521b9cfff2f63b8 (patch)
treef511ed44ab8cb16af257e58ff960da1fd60c5876 /src/stores
parentAdd trial onboarding during signup (diff)
downloadferdium-app-76559f2895012803aed3256ce521b9cfff2f63b8.tar.gz
ferdium-app-76559f2895012803aed3256ce521b9cfff2f63b8.tar.zst
ferdium-app-76559f2895012803aed3256ce521b9cfff2f63b8.zip
WIP: add option to activate trial
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/UserStore.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js
index 6d746254e..e7516e6e6 100644
--- a/src/stores/UserStore.js
+++ b/src/stores/UserStore.js
@@ -2,12 +2,14 @@ import { observable, computed, action } from 'mobx';
2import moment from 'moment'; 2import moment from 'moment';
3import jwt from 'jsonwebtoken'; 3import jwt from 'jsonwebtoken';
4import localStorage from 'mobx-localstorage'; 4import localStorage from 'mobx-localstorage';
5import ms from 'ms';
5 6
6import { isDevMode } from '../environment'; 7import { isDevMode } from '../environment';
7import Store from './lib/Store'; 8import Store from './lib/Store';
8import Request from './lib/Request'; 9import Request from './lib/Request';
9import CachedRequest from './lib/CachedRequest'; 10import CachedRequest from './lib/CachedRequest';
10import { gaEvent } from '../lib/analytics'; 11import { gaEvent } from '../lib/analytics';
12import { sleep } from '../helpers/async-helpers';
11 13
12const debug = require('debug')('Franz:UserStore'); 14const debug = require('debug')('Franz:UserStore');
13 15
@@ -61,6 +63,8 @@ export default class UserStore extends Store {
61 63
62 @observable hasCompletedSignup = false; 64 @observable hasCompletedSignup = false;
63 65
66 @observable hasActivatedTrial = false;
67
64 @observable userData = {}; 68 @observable userData = {};
65 69
66 @observable actionStatus = []; 70 @observable actionStatus = [];
@@ -90,6 +94,7 @@ export default class UserStore extends Store {
90 this.registerReactions([ 94 this.registerReactions([
91 this._requireAuthenticatedUser, 95 this._requireAuthenticatedUser,
92 this._getUserData.bind(this), 96 this._getUserData.bind(this),
97 this._resetTrialActivationState.bind(this),
93 ]); 98 ]);
94 } 99 }
95 100
@@ -211,7 +216,13 @@ export default class UserStore extends Store {
211 216
212 await this.activateTrialRequest._promise; 217 await this.activateTrialRequest._promise;
213 218
219 this.hasActivatedTrial = true;
220
221 console.log('hasActivatedTrial', this.hasActivatedTrial);
222
214 this.stores.features.featuresRequest.invalidate({ immediately: true }); 223 this.stores.features.featuresRequest.invalidate({ immediately: true });
224 this.stores.user.getUserInfoRequest.invalidate({ immediately: true });
225
215 226
216 gaEvent('User', 'activateTrial'); 227 gaEvent('User', 'activateTrial');
217 } 228 }
@@ -335,6 +346,16 @@ export default class UserStore extends Store {
335 } 346 }
336 } 347 }
337 348
349 async _resetTrialActivationState() {
350 if (this.hasActivatedTrial) {
351 await sleep(ms('12s'));
352
353 console.log('resetting this.hasActivatedTrial', this.hasActivatedTrial);
354
355 this.hasActivatedTrial = false;
356 }
357 }
358
338 // Helpers 359 // Helpers
339 _parseToken(authToken) { 360 _parseToken(authToken) {
340 try { 361 try {