Skip to content

Commit

Permalink
feat(Workspaces): Only load workspace related services
Browse files Browse the repository at this point in the history
Only load workspace related services
  • Loading branch information
adlk authored Oct 8, 2019
2 parents 9e539a8 + d3009b9 commit ad7fb84
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/ui/PremiumFeatureContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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({
Expand Down
5 changes: 4 additions & 1 deletion src/containers/layout/AppLayoutContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -41,6 +42,7 @@ export default @inject('stores', 'actions') @observer class AppLayoutContainer e
globalError,
requests,
user,
workspaces,
} = this.props.stores;

const {
Expand Down Expand Up @@ -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 />
Expand Down Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion src/containers/settings/EditSettingsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
9 changes: 8 additions & 1 deletion src/features/delayApp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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');
Expand Down
5 changes: 5 additions & 0 deletions src/features/workspaces/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') || {};
}
Expand Down

0 comments on commit ad7fb84

Please sign in to comment.