Skip to content

Commit 08c40f0

Browse files
committed
fix(App): Fix app delay for Premium Supporters
1 parent eee1fe6 commit 08c40f0

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

src/containers/settings/AccountScreen.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ import ErrorBoundary from '../../components/util/ErrorBoundary';
1414
const { BrowserWindow } = remote;
1515

1616
export default @inject('stores', 'actions') @observer class AccountScreen extends Component {
17+
componentWillMount() {
18+
const {
19+
user,
20+
} = this.props.stores;
21+
22+
user.getUserInfoRequest.invalidate({ immediately: true });
23+
}
24+
1725
componentDidMount() {
1826
gaPage('Settings/Account Dashboard');
1927
}

src/features/delayApp/index.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,23 @@ function setVisibility(value) {
2323
}
2424

2525
export default function init(stores) {
26-
reaction(
27-
() => stores.features.features.needToWaitToProceed,
28-
(enabled, r) => {
29-
if (enabled) {
30-
debug('Initializing `delayApp` feature');
26+
debug('Initializing `delayApp` feature');
3127

32-
// Dispose the reaction to run this only once
33-
r.dispose();
28+
let shownAfterLaunch = false;
29+
let timeLastDelay = moment();
3430

35-
const { needToWaitToProceedConfig: globalConfig } = stores.features.features;
31+
reaction(
32+
() => stores.features.features.needToWaitToProceed && !stores.user.data.isPremium,
33+
(isEnabled) => {
34+
if (isEnabled) {
35+
debug('Enabling `delayApp` feature');
3636

37-
let shownAfterLaunch = false;
38-
let timeLastDelay = moment();
37+
const { needToWaitToProceedConfig: globalConfig } = stores.features.features;
3938

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

4342
autorun(() => {
44-
if (stores.user.data.isPremium) {
45-
debug('Skipping app delay as user is Premium Supporter');
46-
return;
47-
}
48-
4943
if (stores.services.all.length === 0) {
5044
shownAfterLaunch = true;
5145
return;
@@ -68,6 +62,8 @@ export default function init(stores) {
6862
}, DEFAULT_FEATURES_CONFIG.needToWaitToProceedConfig.wait + 1000); // timer needs to be able to hit 0
6963
}
7064
});
65+
} else {
66+
setVisibility(false);
7167
}
7268
},
7369
);

src/stores/FeaturesStore.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { computed, observable } from 'mobx';
1+
import { computed, observable, reaction } from 'mobx';
22

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

2323
await this.featuresRequest._promise;
2424
setTimeout(this._enableFeatures.bind(this), 1);
25+
26+
// single key reaction
27+
reaction(() => this.stores.user.data.isPremium, () => {
28+
if (this.stores.user.isLoggedIn) {
29+
this.featuresRequest.invalidate({ immediately: true });
30+
}
31+
});
2532
}
2633

2734
@computed get anonymousFeatures() {

0 commit comments

Comments
 (0)