Permalink
Browse files

fix(App): Fix app delay for Premium Supporters

  • Loading branch information...
adlk committed Jan 9, 2019
1 parent eee1fe6 commit 08c40f00de99f2e49f07106c241110f7afa71f6c
Showing with 27 additions and 16 deletions.
  1. +8 −0 src/containers/settings/AccountScreen.js
  2. +11 −15 src/features/delayApp/index.js
  3. +8 −1 src/stores/FeaturesStore.js
@@ -14,6 +14,14 @@ import ErrorBoundary from '../../components/util/ErrorBoundary';
const { BrowserWindow } = remote;

export default @inject('stores', 'actions') @observer class AccountScreen extends Component {
componentWillMount() {
const {
user,
} = this.props.stores;

user.getUserInfoRequest.invalidate({ immediately: true });
}

componentDidMount() {
gaPage('Settings/Account Dashboard');
}
@@ -23,29 +23,23 @@ function setVisibility(value) {
}

export default function init(stores) {
reaction(
() => stores.features.features.needToWaitToProceed,
(enabled, r) => {
if (enabled) {
debug('Initializing `delayApp` feature');
debug('Initializing `delayApp` feature');

// Dispose the reaction to run this only once
r.dispose();
let shownAfterLaunch = false;
let timeLastDelay = moment();

const { needToWaitToProceedConfig: globalConfig } = stores.features.features;
reaction(
() => stores.features.features.needToWaitToProceed && !stores.user.data.isPremium,
(isEnabled) => {
if (isEnabled) {
debug('Enabling `delayApp` feature');

let shownAfterLaunch = false;
let timeLastDelay = moment();
const { needToWaitToProceedConfig: globalConfig } = stores.features.features;

config.delayOffset = globalConfig.delayOffset !== undefined ? globalConfig.delayOffset : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.delayOffset;
config.delayDuration = globalConfig.wait !== undefined ? globalConfig.wait : DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait;

autorun(() => {
if (stores.user.data.isPremium) {
debug('Skipping app delay as user is Premium Supporter');
return;
}

if (stores.services.all.length === 0) {
shownAfterLaunch = true;
return;
@@ -68,6 +62,8 @@ export default function init(stores) {
}, DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait + 1000); // timer needs to be able to hit 0
}
});
} else {
setVisibility(false);
}
},
);
@@ -1,4 +1,4 @@
import { computed, observable } from 'mobx';
import { computed, observable, reaction } from 'mobx';

import Store from './lib/Store';
import CachedRequest from './lib/CachedRequest';
@@ -22,6 +22,13 @@ export default class FeaturesStore extends Store {

await this.featuresRequest._promise;
setTimeout(this._enableFeatures.bind(this), 1);

// single key reaction
reaction(() => this.stores.user.data.isPremium, () => {
if (this.stores.user.isLoggedIn) {
this.featuresRequest.invalidate({ immediately: true });
}
});
}

@computed get anonymousFeatures() {

0 comments on commit 08c40f0

Please sign in to comment.