Skip to content
Permalink
Browse files

feat(Workspaces): Setting to keep all workspaces loaded

  • Loading branch information...
DominikGuzei committed Sep 11, 2019
1 parent f309aaf commit ddab3a88b297fe244971b0d4fb9ff3fca3a8a1fe
@@ -102,6 +102,7 @@ export default @observer class EditSettingsForm extends Component {
cacheSize: PropTypes.string.isRequired,
isSpellcheckerIncludedInCurrentPlan: PropTypes.bool.isRequired,
isTodosEnabled: PropTypes.bool.isRequired,
isWorkspaceEnabled: PropTypes.bool.isRequired,
};

static contextTypes = {
@@ -133,6 +134,7 @@ export default @observer class EditSettingsForm extends Component {
cacheSize,
isSpellcheckerIncludedInCurrentPlan,
isTodosEnabled,
isWorkspaceEnabled,
} = this.props;
const { intl } = this.context;

@@ -164,6 +166,9 @@ export default @observer class EditSettingsForm extends Component {
{process.platform === 'win32' && (
<Toggle field={form.$('minimizeToSystemTray')} />
)}
{isWorkspaceEnabled && (
<Toggle field={form.$('keepAllWorkspacesLoaded')} />
)}
{isTodosEnabled && (
<Toggle field={form.$('enableTodos')} />
)}
@@ -19,6 +19,8 @@ import ErrorBoundary from '../../components/util/ErrorBoundary';

import globalMessages from '../../i18n/globalMessages';
import { DEFAULT_IS_FEATURE_ENABLED_BY_USER } from '../../features/todos';
import WorkspacesStore from '../../features/workspaces/store';
import { DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED } from '../../features/workspaces';

const messages = defineMessages({
autoLaunchOnStart: {
@@ -73,6 +75,10 @@ const messages = defineMessages({
id: 'settings.app.form.enableTodos',
defaultMessage: '!!!Enable Franz Todos',
},
keepAllWorkspacesLoaded: {
id: 'settings.app.form.keepAllWorkspacesLoaded',
defaultMessage: '!!!Keep all workspaces loaded',
},
});

export default @inject('stores', 'actions') @observer class EditSettingsScreen extends Component {
@@ -81,12 +87,13 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
};

onSubmit(settingsData) {
const { todos } = this.props.stores;
const { todos, workspaces } = this.props.stores;
const {
app,
settings,
user,
todos: todosActions,
workspaces: workspaceActions,
} = this.props.actions;

app.launchOnStartup({
@@ -118,14 +125,24 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
},
});

if (workspaces.isFeatureActive) {
const { keepAllWorkspacesLoaded } = workspaces.settings;
if (keepAllWorkspacesLoaded !== settingsData.keepAllWorkspacesLoaded) {
workspaceActions.toggleKeepAllWorkspacesLoadedSetting();
}
}

if (todos.isFeatureActive) {
todosActions.toggleTodosFeatureVisibility();
const { isFeatureEnabledByUser } = todos.settings;
if (isFeatureEnabledByUser !== settingsData.enableTodos) {
todosActions.toggleTodosFeatureVisibility();
}
}
}

prepareForm() {
const {
app, settings, user, todos,
app, settings, user, todos, workspaces,
} = this.props.stores;
const { intl } = this.context;

@@ -210,6 +227,14 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
},
};

if (workspaces.isFeatureActive) {
config.fields.keepAllWorkspacesLoaded = {
label: intl.formatMessage(messages.keepAllWorkspacesLoaded),
value: workspaces.settings.keepAllWorkspacesLoaded,
default: DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED,
};
}

if (todos.isFeatureActive) {
config.fields.enableTodos = {
label: intl.formatMessage(messages.enableTodos),
@@ -225,6 +250,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
const {
app,
todos,
workspaces,
} = this.props.stores;
const {
updateStatus,
@@ -255,6 +281,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
onClearAllCache={clearAllCache}
isSpellcheckerIncludedInCurrentPlan={spellcheckerConfig.isIncludedInCurrentPlan}
isTodosEnabled={todos.isFeatureActive}
isWorkspaceEnabled={workspaces.isFeatureActive}
/>
</ErrorBoundary>
);
@@ -267,6 +294,7 @@ EditSettingsScreen.wrappedComponent.propTypes = {
user: PropTypes.instanceOf(UserStore).isRequired,
settings: PropTypes.instanceOf(SettingsStore).isRequired,
todos: PropTypes.instanceOf(TodosStore).isRequired,
workspaces: PropTypes.instanceOf(WorkspacesStore).isRequired,
}).isRequired,
actions: PropTypes.shape({
app: PropTypes.shape({
@@ -284,5 +312,8 @@ EditSettingsScreen.wrappedComponent.propTypes = {
todos: PropTypes.shape({
toggleTodosFeatureVisibility: PropTypes.func.isRequired,
}).isRequired,
workspaces: PropTypes.shape({
toggleAllWorkspacesLoadedSetting: PropTypes.func.isRequired,
}).isRequired,
}).isRequired,
};
@@ -21,6 +21,7 @@ export const workspaceActions = createActionsFromDefinitions({
deactivate: {},
toggleWorkspaceDrawer: {},
openWorkspaceSettings: {},
toggleKeepAllWorkspacesLoadedSetting: {},
}, PropTypes.checkPropTypes);

export default workspaceActions;
@@ -5,6 +5,7 @@ import { resetApiRequests } from './api';
const debug = require('debug')('Franz:feature:workspaces');

export const GA_CATEGORY_WORKSPACES = 'Workspaces';
export const DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED = false;

export const workspaceStore = new WorkspacesStore();

@@ -97,6 +97,7 @@ export default class WorkspacesStore extends FeatureStore {
[workspaceActions.update, this._update],
[workspaceActions.activate, this._setActiveWorkspace],
[workspaceActions.deactivate, this._deactivateActiveWorkspace],
[workspaceActions.toggleKeepAllWorkspacesLoadedSetting, this._toggleKeepAllWorkspacesLoadedSetting],
]);
this._allActions = this._freeUserActions.concat(this._premiumUserActions);
this._registerActions(this._allActions);
@@ -245,6 +246,10 @@ export default class WorkspacesStore extends FeatureStore {
await updateWorkspaceRequest.execute(activeWorkspace);
};

_toggleKeepAllWorkspacesLoadedSetting = async () => {
this._updateSettings({ keepAllWorkspacesLoaded: !this.settings.keepAllWorkspacesLoaded });
};

// Reactions

_setFeatureEnabledReaction = () => {
@@ -4,11 +4,11 @@
"defaultMessage": "!!!Launch Franz on start",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 24,
"line": 26,
"column": 21
},
"end": {
"line": 27,
"line": 29,
"column": 3
}
},
@@ -17,11 +17,11 @@
"defaultMessage": "!!!Open in background",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 28,
"line": 30,
"column": 26
},
"end": {
"line": 31,
"line": 33,
"column": 3
}
},
@@ -30,11 +30,11 @@
"defaultMessage": "!!!Keep Franz in background when closing the window",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 32,
"line": 34,
"column": 19
},
"end": {
"line": 35,
"line": 37,
"column": 3
}
},
@@ -43,11 +43,11 @@
"defaultMessage": "!!!Show Franz in system tray",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 36,
"line": 38,
"column": 20
},
"end": {
"line": 39,
"line": 41,
"column": 3
}
},
@@ -56,11 +56,11 @@
"defaultMessage": "!!!Minimize Franz to system tray",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 40,
"line": 42,
"column": 24
},
"end": {
"line": 43,
"line": 45,
"column": 3
}
},
@@ -69,11 +69,11 @@
"defaultMessage": "!!!Language",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 44,
"line": 46,
"column": 12
},
"end": {
"line": 47,
"line": 49,
"column": 3
}
},
@@ -82,11 +82,11 @@
"defaultMessage": "!!!Dark Mode",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 48,
"line": 50,
"column": 12
},
"end": {
"line": 51,
"line": 53,
"column": 3
}
},
@@ -95,11 +95,11 @@
"defaultMessage": "!!!Display disabled services tabs",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 52,
"line": 54,
"column": 24
},
"end": {
"line": 55,
"line": 57,
"column": 3
}
},
@@ -108,11 +108,11 @@
"defaultMessage": "!!!Show unread message badge when notifications are disabled",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 56,
"line": 58,
"column": 29
},
"end": {
"line": 59,
"line": 61,
"column": 3
}
},
@@ -121,11 +121,11 @@
"defaultMessage": "!!!Enable spell checking",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 60,
"line": 62,
"column": 23
},
"end": {
"line": 63,
"line": 65,
"column": 3
}
},
@@ -134,11 +134,11 @@
"defaultMessage": "!!!Enable GPU Acceleration",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 64,
"line": 66,
"column": 25
},
"end": {
"line": 67,
"line": 69,
"column": 3
}
},
@@ -147,11 +147,11 @@
"defaultMessage": "!!!Include beta versions",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 68,
"line": 70,
"column": 8
},
"end": {
"line": 71,
"line": 73,
"column": 3
}
},
@@ -160,11 +160,24 @@
"defaultMessage": "!!!Enable Franz Todos",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 72,
"line": 74,
"column": 15
},
"end": {
"line": 75,
"line": 77,
"column": 3
}
},
{
"id": "settings.app.form.keepAllWorkspacesLoaded",
"defaultMessage": "!!!Keep all workspaces loaded",
"file": "src/containers/settings/EditSettingsScreen.js",
"start": {
"line": 78,
"column": 27
},
"end": {
"line": 81,
"column": 3
}
}
@@ -121,10 +121,10 @@ export default class ServicesStore extends Store {

// This is just used to avoid unnecessary rerendering of resource-heavy webviews
@computed get allDisplayedUnordered() {
const { showDisabledServices } = this.stores.settings.all.app;
const { showDisabledServices, keepAllWorkspacesLoaded } = this.stores.settings.all.app;
const services = this.allServicesRequest.execute().result || [];
const filteredServices = showDisabledServices ? services : services.filter(service => service.isEnabled);
return workspaceStore.filterServicesByActiveWorkspace(filteredServices);
return keepAllWorkspacesLoaded ? filteredServices : workspaceStore.filterServicesByActiveWorkspace(filteredServices);
}

@computed get filtered() {

1 comment on commit ddab3a8

@Stanzilla

This comment has been minimized.

Copy link
Contributor

commented on ddab3a8 Sep 13, 2019

@DominikGuzei the toggle does not seem to work

Please sign in to comment.
You can’t perform that action at this time.