Skip to content

Commit ddab3a8

Browse files
committed
feat(Workspaces): Setting to keep all workspaces loaded
1 parent f309aaf commit ddab3a8

File tree

7 files changed

+87
-31
lines changed

7 files changed

+87
-31
lines changed

src/components/settings/settings/EditSettingsForm.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export default @observer class EditSettingsForm extends Component {
102102
cacheSize: PropTypes.string.isRequired,
103103
isSpellcheckerIncludedInCurrentPlan: PropTypes.bool.isRequired,
104104
isTodosEnabled: PropTypes.bool.isRequired,
105+
isWorkspaceEnabled: PropTypes.bool.isRequired,
105106
};
106107

107108
static contextTypes = {
@@ -133,6 +134,7 @@ export default @observer class EditSettingsForm extends Component {
133134
cacheSize,
134135
isSpellcheckerIncludedInCurrentPlan,
135136
isTodosEnabled,
137+
isWorkspaceEnabled,
136138
} = this.props;
137139
const { intl } = this.context;
138140

@@ -164,6 +166,9 @@ export default @observer class EditSettingsForm extends Component {
164166
{process.platform === 'win32' && (
165167
<Toggle field={form.$('minimizeToSystemTray')} />
166168
)}
169+
{isWorkspaceEnabled && (
170+
<Toggle field={form.$('keepAllWorkspacesLoaded')} />
171+
)}
167172
{isTodosEnabled && (
168173
<Toggle field={form.$('enableTodos')} />
169174
)}

src/containers/settings/EditSettingsScreen.js

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import ErrorBoundary from '../../components/util/ErrorBoundary';
1919

2020
import globalMessages from '../../i18n/globalMessages';
2121
import { DEFAULT_IS_FEATURE_ENABLED_BY_USER } from '../../features/todos';
22+
import WorkspacesStore from '../../features/workspaces/store';
23+
import { DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED } from '../../features/workspaces';
2224

2325
const messages = defineMessages({
2426
autoLaunchOnStart: {
@@ -73,6 +75,10 @@ const messages = defineMessages({
7375
id: 'settings.app.form.enableTodos',
7476
defaultMessage: '!!!Enable Franz Todos',
7577
},
78+
keepAllWorkspacesLoaded: {
79+
id: 'settings.app.form.keepAllWorkspacesLoaded',
80+
defaultMessage: '!!!Keep all workspaces loaded',
81+
},
7682
});
7783

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

8389
onSubmit(settingsData) {
84-
const { todos } = this.props.stores;
90+
const { todos, workspaces } = this.props.stores;
8591
const {
8692
app,
8793
settings,
8894
user,
8995
todos: todosActions,
96+
workspaces: workspaceActions,
9097
} = this.props.actions;
9198

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

128+
if (workspaces.isFeatureActive) {
129+
const { keepAllWorkspacesLoaded } = workspaces.settings;
130+
if (keepAllWorkspacesLoaded !== settingsData.keepAllWorkspacesLoaded) {
131+
workspaceActions.toggleKeepAllWorkspacesLoadedSetting();
132+
}
133+
}
134+
121135
if (todos.isFeatureActive) {
122-
todosActions.toggleTodosFeatureVisibility();
136+
const { isFeatureEnabledByUser } = todos.settings;
137+
if (isFeatureEnabledByUser !== settingsData.enableTodos) {
138+
todosActions.toggleTodosFeatureVisibility();
139+
}
123140
}
124141
}
125142

126143
prepareForm() {
127144
const {
128-
app, settings, user, todos,
145+
app, settings, user, todos, workspaces,
129146
} = this.props.stores;
130147
const { intl } = this.context;
131148

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

230+
if (workspaces.isFeatureActive) {
231+
config.fields.keepAllWorkspacesLoaded = {
232+
label: intl.formatMessage(messages.keepAllWorkspacesLoaded),
233+
value: workspaces.settings.keepAllWorkspacesLoaded,
234+
default: DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED,
235+
};
236+
}
237+
213238
if (todos.isFeatureActive) {
214239
config.fields.enableTodos = {
215240
label: intl.formatMessage(messages.enableTodos),
@@ -225,6 +250,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
225250
const {
226251
app,
227252
todos,
253+
workspaces,
228254
} = this.props.stores;
229255
const {
230256
updateStatus,
@@ -255,6 +281,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
255281
onClearAllCache={clearAllCache}
256282
isSpellcheckerIncludedInCurrentPlan={spellcheckerConfig.isIncludedInCurrentPlan}
257283
isTodosEnabled={todos.isFeatureActive}
284+
isWorkspaceEnabled={workspaces.isFeatureActive}
258285
/>
259286
</ErrorBoundary>
260287
);
@@ -267,6 +294,7 @@ EditSettingsScreen.wrappedComponent.propTypes = {
267294
user: PropTypes.instanceOf(UserStore).isRequired,
268295
settings: PropTypes.instanceOf(SettingsStore).isRequired,
269296
todos: PropTypes.instanceOf(TodosStore).isRequired,
297+
workspaces: PropTypes.instanceOf(WorkspacesStore).isRequired,
270298
}).isRequired,
271299
actions: PropTypes.shape({
272300
app: PropTypes.shape({
@@ -284,5 +312,8 @@ EditSettingsScreen.wrappedComponent.propTypes = {
284312
todos: PropTypes.shape({
285313
toggleTodosFeatureVisibility: PropTypes.func.isRequired,
286314
}).isRequired,
315+
workspaces: PropTypes.shape({
316+
toggleAllWorkspacesLoadedSetting: PropTypes.func.isRequired,
317+
}).isRequired,
287318
}).isRequired,
288319
};

src/features/workspaces/actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const workspaceActions = createActionsFromDefinitions({
2121
deactivate: {},
2222
toggleWorkspaceDrawer: {},
2323
openWorkspaceSettings: {},
24+
toggleKeepAllWorkspacesLoadedSetting: {},
2425
}, PropTypes.checkPropTypes);
2526

2627
export default workspaceActions;

src/features/workspaces/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { resetApiRequests } from './api';
55
const debug = require('debug')('Franz:feature:workspaces');
66

77
export const GA_CATEGORY_WORKSPACES = 'Workspaces';
8+
export const DEFAULT_SETTING_KEEP_ALL_WORKSPACES_LOADED = false;
89

910
export const workspaceStore = new WorkspacesStore();
1011

src/features/workspaces/store.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export default class WorkspacesStore extends FeatureStore {
9797
[workspaceActions.update, this._update],
9898
[workspaceActions.activate, this._setActiveWorkspace],
9999
[workspaceActions.deactivate, this._deactivateActiveWorkspace],
100+
[workspaceActions.toggleKeepAllWorkspacesLoadedSetting, this._toggleKeepAllWorkspacesLoadedSetting],
100101
]);
101102
this._allActions = this._freeUserActions.concat(this._premiumUserActions);
102103
this._registerActions(this._allActions);
@@ -245,6 +246,10 @@ export default class WorkspacesStore extends FeatureStore {
245246
await updateWorkspaceRequest.execute(activeWorkspace);
246247
};
247248

249+
_toggleKeepAllWorkspacesLoadedSetting = async () => {
250+
this._updateSettings({ keepAllWorkspacesLoaded: !this.settings.keepAllWorkspacesLoaded });
251+
};
252+
248253
// Reactions
249254

250255
_setFeatureEnabledReaction = () => {

src/i18n/messages/src/containers/settings/EditSettingsScreen.json

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"defaultMessage": "!!!Launch Franz on start",
55
"file": "src/containers/settings/EditSettingsScreen.js",
66
"start": {
7-
"line": 24,
7+
"line": 26,
88
"column": 21
99
},
1010
"end": {
11-
"line": 27,
11+
"line": 29,
1212
"column": 3
1313
}
1414
},
@@ -17,11 +17,11 @@
1717
"defaultMessage": "!!!Open in background",
1818
"file": "src/containers/settings/EditSettingsScreen.js",
1919
"start": {
20-
"line": 28,
20+
"line": 30,
2121
"column": 26
2222
},
2323
"end": {
24-
"line": 31,
24+
"line": 33,
2525
"column": 3
2626
}
2727
},
@@ -30,11 +30,11 @@
3030
"defaultMessage": "!!!Keep Franz in background when closing the window",
3131
"file": "src/containers/settings/EditSettingsScreen.js",
3232
"start": {
33-
"line": 32,
33+
"line": 34,
3434
"column": 19
3535
},
3636
"end": {
37-
"line": 35,
37+
"line": 37,
3838
"column": 3
3939
}
4040
},
@@ -43,11 +43,11 @@
4343
"defaultMessage": "!!!Show Franz in system tray",
4444
"file": "src/containers/settings/EditSettingsScreen.js",
4545
"start": {
46-
"line": 36,
46+
"line": 38,
4747
"column": 20
4848
},
4949
"end": {
50-
"line": 39,
50+
"line": 41,
5151
"column": 3
5252
}
5353
},
@@ -56,11 +56,11 @@
5656
"defaultMessage": "!!!Minimize Franz to system tray",
5757
"file": "src/containers/settings/EditSettingsScreen.js",
5858
"start": {
59-
"line": 40,
59+
"line": 42,
6060
"column": 24
6161
},
6262
"end": {
63-
"line": 43,
63+
"line": 45,
6464
"column": 3
6565
}
6666
},
@@ -69,11 +69,11 @@
6969
"defaultMessage": "!!!Language",
7070
"file": "src/containers/settings/EditSettingsScreen.js",
7171
"start": {
72-
"line": 44,
72+
"line": 46,
7373
"column": 12
7474
},
7575
"end": {
76-
"line": 47,
76+
"line": 49,
7777
"column": 3
7878
}
7979
},
@@ -82,11 +82,11 @@
8282
"defaultMessage": "!!!Dark Mode",
8383
"file": "src/containers/settings/EditSettingsScreen.js",
8484
"start": {
85-
"line": 48,
85+
"line": 50,
8686
"column": 12
8787
},
8888
"end": {
89-
"line": 51,
89+
"line": 53,
9090
"column": 3
9191
}
9292
},
@@ -95,11 +95,11 @@
9595
"defaultMessage": "!!!Display disabled services tabs",
9696
"file": "src/containers/settings/EditSettingsScreen.js",
9797
"start": {
98-
"line": 52,
98+
"line": 54,
9999
"column": 24
100100
},
101101
"end": {
102-
"line": 55,
102+
"line": 57,
103103
"column": 3
104104
}
105105
},
@@ -108,11 +108,11 @@
108108
"defaultMessage": "!!!Show unread message badge when notifications are disabled",
109109
"file": "src/containers/settings/EditSettingsScreen.js",
110110
"start": {
111-
"line": 56,
111+
"line": 58,
112112
"column": 29
113113
},
114114
"end": {
115-
"line": 59,
115+
"line": 61,
116116
"column": 3
117117
}
118118
},
@@ -121,11 +121,11 @@
121121
"defaultMessage": "!!!Enable spell checking",
122122
"file": "src/containers/settings/EditSettingsScreen.js",
123123
"start": {
124-
"line": 60,
124+
"line": 62,
125125
"column": 23
126126
},
127127
"end": {
128-
"line": 63,
128+
"line": 65,
129129
"column": 3
130130
}
131131
},
@@ -134,11 +134,11 @@
134134
"defaultMessage": "!!!Enable GPU Acceleration",
135135
"file": "src/containers/settings/EditSettingsScreen.js",
136136
"start": {
137-
"line": 64,
137+
"line": 66,
138138
"column": 25
139139
},
140140
"end": {
141-
"line": 67,
141+
"line": 69,
142142
"column": 3
143143
}
144144
},
@@ -147,11 +147,11 @@
147147
"defaultMessage": "!!!Include beta versions",
148148
"file": "src/containers/settings/EditSettingsScreen.js",
149149
"start": {
150-
"line": 68,
150+
"line": 70,
151151
"column": 8
152152
},
153153
"end": {
154-
"line": 71,
154+
"line": 73,
155155
"column": 3
156156
}
157157
},
@@ -160,11 +160,24 @@
160160
"defaultMessage": "!!!Enable Franz Todos",
161161
"file": "src/containers/settings/EditSettingsScreen.js",
162162
"start": {
163-
"line": 72,
163+
"line": 74,
164164
"column": 15
165165
},
166166
"end": {
167-
"line": 75,
167+
"line": 77,
168+
"column": 3
169+
}
170+
},
171+
{
172+
"id": "settings.app.form.keepAllWorkspacesLoaded",
173+
"defaultMessage": "!!!Keep all workspaces loaded",
174+
"file": "src/containers/settings/EditSettingsScreen.js",
175+
"start": {
176+
"line": 78,
177+
"column": 27
178+
},
179+
"end": {
180+
"line": 81,
168181
"column": 3
169182
}
170183
}

src/stores/ServicesStore.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ export default class ServicesStore extends Store {
121121

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

130130
@computed get filtered() {

0 commit comments

Comments
 (0)