Add option to hibernate unused workspaces at app launch (#97)

This commit is contained in:
Quang Lam 2020-01-03 04:03:23 -06:00 committed by GitHub
parent e175cb78d8
commit 91f8e9e96c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View file

@ -42,6 +42,8 @@ if (!gotTheLock) {
loadListeners();
const commonInit = () => {
const hibernateUnusedWorkspacesAtLaunch = getPreference('hibernateUnusedWorkspacesAtLaunch');
mainWindow.createAsync()
.then(() => {
createMenu();
@ -50,7 +52,10 @@ if (!gotTheLock) {
Object.keys(workspaceObjects).forEach((id) => {
const workspace = workspaceObjects[id];
if (workspace.hibernateWhenUnused && !workspace.active) {
if (
(hibernateUnusedWorkspacesAtLaunch || workspace.hibernateWhenUnused)
&& !workspace.active
) {
if (!workspace.hibernated) {
setWorkspace(workspace.id, { hibernated: true });
}

View file

@ -89,6 +89,7 @@ const defaultPreferences = {
attachToMenubar: false,
cssCodeInjection: null,
downloadPath: getDefaultDownloadsPath(),
hibernateUnusedWorkspacesAtLaunch: false,
jsCodeInjection: null,
navigationBar: false,
pauseNotifications: null,

View file

@ -125,6 +125,7 @@ const Preferences = ({
classes,
cssCodeInjection,
downloadPath,
hibernateUnusedWorkspacesAtLaunch,
isDefaultMailClient,
isDefaultWebBrowser,
jsCodeInjection,
@ -514,6 +515,22 @@ const Preferences = ({
</Typography>
<Paper className={classes.paper}>
<List dense>
<ListItem>
<ListItemText
primary="Hibernate unused workspaces at app launch"
secondary="Hibernate all workspaces at launch, except the last active workspace."
/>
<ListItemSecondaryAction>
<Switch
color="primary"
checked={hibernateUnusedWorkspacesAtLaunch}
onChange={(e) => {
requestSetPreference('hibernateUnusedWorkspacesAtLaunch', e.target.checked);
}}
/>
</ListItemSecondaryAction>
</ListItem>
<Divider />
<ListItem button onClick={() => requestShowCodeInjectionWindow('js')}>
<ListItemText primary="JS Code Injection" secondary={jsCodeInjection ? 'Set' : 'Not set'} />
<ChevronRightIcon color="action" />
@ -568,6 +585,7 @@ Preferences.propTypes = {
classes: PropTypes.object.isRequired,
cssCodeInjection: PropTypes.string,
downloadPath: PropTypes.string.isRequired,
hibernateUnusedWorkspacesAtLaunch: PropTypes.bool.isRequired,
isDefaultMailClient: PropTypes.bool.isRequired,
isDefaultWebBrowser: PropTypes.bool.isRequired,
jsCodeInjection: PropTypes.string,
@ -594,6 +612,7 @@ const mapStateToProps = (state) => ({
attachToMenubar: state.preferences.attachToMenubar,
cssCodeInjection: state.preferences.cssCodeInjection,
downloadPath: state.preferences.downloadPath,
hibernateUnusedWorkspacesAtLaunch: state.preferences.hibernateUnusedWorkspacesAtLaunch,
isDefaultMailClient: state.general.isDefaultMailClient,
isDefaultWebBrowser: state.general.isDefaultWebBrowser,
jsCodeInjection: state.preferences.jsCodeInjection,