Skip to content

Commit

Permalink
Add missing delayApp commit
Browse files Browse the repository at this point in the history
  • Loading branch information
adlk committed Nov 24, 2018
1 parent df4d195 commit 217cb8c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/components/layout/AppLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { defineMessages, intlShape } from 'react-intl';
import { TitleBar } from 'electron-react-titlebar';

import InfoBar from '../ui/InfoBar';
import { component as DelayApp } from '../../features/delayApp';
import globalMessages from '../../i18n/globalMessages';

import { isWindows } from '../../environment';
Expand Down Expand Up @@ -58,6 +59,7 @@ export default @observer class AppLayout extends Component {
retryRequiredRequests: PropTypes.func.isRequired,
areRequiredRequestsLoading: PropTypes.bool.isRequired,
darkMode: PropTypes.bool.isRequired,
isDelayAppScreenVisible: PropTypes.bool.isRequired,
};

static defaultProps = {
Expand Down Expand Up @@ -86,6 +88,7 @@ export default @observer class AppLayout extends Component {
retryRequiredRequests,
areRequiredRequestsLoading,
darkMode,
isDelayAppScreenVisible,
} = this.props;

const { intl } = this.context;
Expand Down Expand Up @@ -152,6 +155,7 @@ export default @observer class AppLayout extends Component {
</a>
</InfoBar>
)}
{isDelayAppScreenVisible && (<DelayApp />)}
{services}
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/containers/layout/AppLayoutContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import Sidebar from '../../components/layout/Sidebar';
import Services from '../../components/services/content/Services';
import AppLoader from '../../components/ui/AppLoader';

import { state as delayAppState } from '../../features/delayApp';

export default @inject('stores', 'actions') @observer class AppLayoutContainer extends Component {
static defaultProps = {
children: null,
Expand Down Expand Up @@ -128,6 +130,7 @@ export default @inject('stores', 'actions') @observer class AppLayoutContainer e
retryRequiredRequests={retryRequiredRequests}
areRequiredRequestsLoading={requests.areRequiredRequestsLoading}
darkMode={settings.all.app.darkMode}
isDelayAppScreenVisible={delayAppState.isDelayAppScreenVisible}
>
{React.Children.count(children) > 0 ? children : null}
</AppLayout>
Expand Down
5 changes: 4 additions & 1 deletion src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,8 @@
"validation.required": "{field} is required",
"validation.email": "{field} is not valid",
"validation.url": "{field} is not a valid URL",
"validation.minLength": "{field} should be at least {length} characters long"
"validation.minLength": "{field} should be at least {length} characters long",
"feature.delayApp.headline": "Please purchase a Franz Supporter License to skip waiting",
"feature.delayApp.action": "Get a Franz Supporter License",
"feature.delayApp.text": "Franz will continue in {seconds} seconds."
}
14 changes: 14 additions & 0 deletions src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config';
import { isMac, isLinux, isWindows } from '../environment';
import locales from '../i18n/translations';
import { gaEvent } from '../lib/analytics';
import { onVisibilityChange } from '../helpers/visibility-helper';

import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js';

Expand Down Expand Up @@ -56,6 +57,8 @@ export default class AppStore extends Store {
@observable isFullScreen = mainWindow.isFullScreen();
@observable isFocused = true;
constructor(...args) {
super(...args);
Expand Down Expand Up @@ -163,6 +166,17 @@ export default class AppStore extends Store {
this._healthCheck();
this.isSystemDarkModeEnabled = systemPreferences.isDarkMode();
onVisibilityChange((isVisible) => {
this.isFocused = isVisible;
// debug('Last focus', moment().diff(this.timeLastFocusStart));
// if (isVisible) {
// this.timeLastFocusStart = moment();
// }
debug('Window is visible/focused', isVisible);
});
}
@computed get cacheSize() {
Expand Down
16 changes: 10 additions & 6 deletions src/stores/FeaturesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ import { computed, observable } from 'mobx';
import Store from './lib/Store';
import CachedRequest from './lib/CachedRequest';

import delayApp from '../features/delayApp';

export default class FeaturesStore extends Store {
@observable defaultFeaturesRequest = new CachedRequest(this.api.features, 'default');
@observable featuresRequest = new CachedRequest(this.api.features, 'features');

setup() {
async setup() {
this.registerReactions([
this._monitorLoginStatus.bind(this),
this._debugFeatures.bind(this),
]);

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

@computed get features() {
Expand All @@ -22,15 +26,15 @@ export default class FeaturesStore extends Store {
return this.defaultFeaturesRequest.execute().result || {};
}

_debugFeatures() {
console.log(this.features);
}

_monitorLoginStatus() {
if (this.stores.user.isLoggedIn) {
this.featuresRequest.invalidate({ immediately: true });
} else {
this.defaultFeaturesRequest.invalidate({ immediately: true });
}
}

_enableFeatures() {
delayApp(this.stores, this.actions);
}
}

0 comments on commit 217cb8c

Please sign in to comment.