Skip to content
Permalink
Browse files
feat(Workspaces): Only load workspace related services
Only load workspace related services
  • Loading branch information
adlk committed Oct 8, 2019
2 parents 9e539a8 + d3009b9 commit ad7fb84e5a193c2db1a8a1a59edf17374a3615d0
@@ -10,7 +10,7 @@ import UserStore from '../../../stores/UserStore';

import styles from './styles';
import { gaEvent } from '../../../lib/analytics';
import { FeatureStore } from '../../../features/utils/FeatureStore';
import FeaturesStore from '../../../stores/FeaturesStore';

const messages = defineMessages({
action: {
@@ -96,7 +96,7 @@ PremiumFeatureContainer.wrappedComponent.propTypes = {
children: oneOrManyChildElements.isRequired,
stores: PropTypes.shape({
user: PropTypes.instanceOf(UserStore).isRequired,
features: PropTypes.instanceOf(FeatureStore).isRequired,
features: PropTypes.instanceOf(FeaturesStore).isRequired,
}).isRequired,
actions: PropTypes.shape({
ui: PropTypes.shape({
@@ -24,6 +24,7 @@ import { state as delayAppState } from '../../features/delayApp';
import { workspaceActions } from '../../features/workspaces/actions';
import WorkspaceDrawer from '../../features/workspaces/components/WorkspaceDrawer';
import { workspaceStore } from '../../features/workspaces';
import WorkspacesStore from '../../features/workspaces/store';

export default @inject('stores', 'actions') @observer class AppLayoutContainer extends Component {
static defaultProps = {
@@ -41,6 +42,7 @@ export default @inject('stores', 'actions') @observer class AppLayoutContainer e
globalError,
requests,
user,
workspaces,
} = this.props.stores;

const {
@@ -79,7 +81,7 @@ export default @inject('stores', 'actions') @observer class AppLayoutContainer e
const isLoadingServices = services.allServicesRequest.isExecuting
&& services.allServicesRequest.isExecutingFirstTime;

if (isLoadingFeatures || isLoadingServices) {
if (isLoadingFeatures || isLoadingServices || workspaces.isLoadingWorkspaces) {
return (
<ThemeProvider theme={ui.theme}>
<AppLoader />
@@ -174,6 +176,7 @@ AppLayoutContainer.wrappedComponent.propTypes = {
user: PropTypes.instanceOf(UserStore).isRequired,
requests: PropTypes.instanceOf(RequestStore).isRequired,
globalError: PropTypes.instanceOf(GlobalErrorStore).isRequired,
workspaces: PropTypes.instanceOf(WorkspacesStore).isRequired,
}).isRequired,
actions: PropTypes.shape({
service: PropTypes.shape({
@@ -313,7 +313,7 @@ EditSettingsScreen.wrappedComponent.propTypes = {
toggleTodosFeatureVisibility: PropTypes.func.isRequired,
}).isRequired,
workspaces: PropTypes.shape({
toggleAllWorkspacesLoadedSetting: PropTypes.func.isRequired,
toggleKeepAllWorkspacesLoadedSetting: PropTypes.func.isRequired,
}).isRequired,
}).isRequired,
};
@@ -4,6 +4,7 @@ import DelayAppComponent from './Component';

import { DEFAULT_FEATURES_CONFIG } from '../../config';
import { gaEvent, gaPage } from '../../lib/analytics';
import { getUserWorkspacesRequest } from '../workspaces/api';

const debug = require('debug')('Franz:feature:delayApp');

@@ -33,7 +34,13 @@ export default function init(stores) {
};

reaction(
() => stores.user.isLoggedIn && stores.services.allServicesRequest.wasExecuted && stores.features.features.needToWaitToProceed && !stores.user.data.isPremium,
() => (
stores.user.isLoggedIn
&& stores.services.allServicesRequest.wasExecuted
&& getUserWorkspacesRequest.wasExecuted
&& stores.features.features.needToWaitToProceed
&& !stores.user.data.isPremium
),
(isEnabled) => {
if (isEnabled) {
debug('Enabling `delayApp` feature');
@@ -45,6 +45,11 @@ export default class WorkspacesStore extends FeatureStore {
return getUserWorkspacesRequest.result || [];
}

@computed get isLoadingWorkspaces() {
if (!this.isFeatureActive) return false;
return getUserWorkspacesRequest.isExecutingFirstTime;
}

@computed get settings() {
return localStorage.getItem('workspaces') || {};
}

0 comments on commit ad7fb84

Please sign in to comment.