Skip to content

Commit

Permalink
fix(App): Fix app delay for Premium Supporters
Browse files Browse the repository at this point in the history
  • Loading branch information
adlk committed Jan 9, 2019
1 parent eee1fe6 commit 08c40f0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
8 changes: 8 additions & 0 deletions src/containers/settings/AccountScreen.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import ErrorBoundary from '../../components/util/ErrorBoundary';
const { BrowserWindow } = remote; const { BrowserWindow } = remote;


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

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

componentDidMount() { componentDidMount() {
gaPage('Settings/Account Dashboard'); gaPage('Settings/Account Dashboard');
} }
Expand Down
26 changes: 11 additions & 15 deletions src/features/delayApp/index.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,29 +23,23 @@ function setVisibility(value) {
} }


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


// Dispose the reaction to run this only once let shownAfterLaunch = false;
r.dispose(); 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; const { needToWaitToProceedConfig: globalConfig } = stores.features.features;
let timeLastDelay = moment();


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


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

if (stores.services.all.length === 0) { if (stores.services.all.length === 0) {
shownAfterLaunch = true; shownAfterLaunch = true;
return; return;
Expand All @@ -68,6 +62,8 @@ export default function init(stores) {
}, DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait + 1000); // timer needs to be able to hit 0 }, DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait + 1000); // timer needs to be able to hit 0
} }
}); });
} else {
setVisibility(false);
} }
}, },
); );
Expand Down
9 changes: 8 additions & 1 deletion src/stores/FeaturesStore.js
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computed, observable } from 'mobx'; import { computed, observable, reaction } from 'mobx';


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


await this.featuresRequest._promise; await this.featuresRequest._promise;
setTimeout(this._enableFeatures.bind(this), 1); 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() { @computed get anonymousFeatures() {
Expand Down

0 comments on commit 08c40f0

Please sign in to comment.