Skip to content

Commit

Permalink
Merge tag 'v1.10.15' into sc
Browse files Browse the repository at this point in the history
* Fix missing element desktop preferences ([\#8798](matrix-org/matrix-react-sdk#8798)). Contributed by @t3chguy.
  • Loading branch information
su-ex committed Jun 16, 2022
2 parents 48f1b64 + 41deac3 commit d3cd2c9
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 42 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Changes in [1.10.15](https://github.com/vector-im/element-desktop/releases/tag/v1.10.15) (2022-06-14)
=====================================================================================================

## 🐛 Bug Fixes
* Fix missing element desktop preferences ([\#8798](https://github.com/matrix-org/matrix-react-sdk/pull/8798)). Contributed by @t3chguy.

Changes in [1.10.14](https://github.com/vector-im/element-desktop/releases/tag/v1.10.14) (2022-06-07)
=====================================================================================================

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "element-desktop",
"productName": "Element",
"main": "lib/electron-main.js",
"version": "1.10.14",
"version": "1.10.15",
"description": "A feature-rich client for Matrix.org",
"author": "Element",
"repository": {
Expand Down
112 changes: 71 additions & 41 deletions src/electron-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,66 @@ ipcMain.on('app_onAction', function(_ev: IpcMainEvent, payload) {
}
});

interface Setting {
read(): Promise<any>;
write(value: any): Promise<void>;
}

const settings: Record<string, Setting> = {
"Electron.autoLaunch": {
async read(): Promise<any> {
return launcher.isEnabled();
},
async write(value: any): Promise<void> {
if (value) {
return launcher.enable();
} else {
return launcher.disable();
}
},
},
"Electron.warnBeforeExit": {
async read(): Promise<any> {
return store.get("warnBeforeExit", true);
},
async write(value: any): Promise<void> {
store.set("warnBeforeExit", value);
},
},
"Electron.alwaysShowMenuBar": { // not supported on macOS
async read(): Promise<any> {
return !global.mainWindow.autoHideMenuBar;
},
async write(value: any): Promise<void> {
store.set('autoHideMenuBar', !value);
global.mainWindow.autoHideMenuBar = !value;
global.mainWindow.setMenuBarVisibility(value);
},
},
"Electron.showTrayIcon": { // not supported on macOS
async read(): Promise<any> {
return tray.hasTray();
},
async write(value: any): Promise<void> {
if (value) {
// Create trayIcon icon
tray.create(trayConfig);
} else {
tray.destroy();
}
store.set('minimizeToTray', value);
},
},
"Electron.enableHardwareAcceleration": {
async read(): Promise<any> {
return !store.get('disableHardwareAcceleration', false);
},
async write(value: any): Promise<void> {
store.set('disableHardwareAcceleration', !value);
},
},
};

ipcMain.on('ipcCall', async function(_ev: IpcMainEvent, payload) {
if (!mainWindow) return;

Expand All @@ -400,51 +460,21 @@ ipcMain.on('ipcCall', async function(_ev: IpcMainEvent, payload) {
case 'getUpdateFeedUrl':
ret = autoUpdater.getFeedURL();
break;
case 'getAutoLaunchEnabled':
ret = await launcher.isEnabled();
case 'getSettingValue': {
const [settingName] = args;
const setting = settings[settingName];
ret = await setting.read();
break;
case 'setAutoLaunchEnabled':
if (args[0]) {
launcher.enable();
} else {
launcher.disable();
}
}
case 'setSettingValue': {
const [settingName, value] = args;
const setting = settings[settingName];
await setting.write(value);
break;
}
case 'setLanguage':
appLocalization.setAppLocale(args[0]);
break;
case 'shouldWarnBeforeExit':
ret = store.get('warnBeforeExit', true);
break;
case 'setWarnBeforeExit':
store.set('warnBeforeExit', args[0]);
break;
case 'getMinimizeToTrayEnabled':
ret = tray.hasTray();
break;
case 'setMinimizeToTrayEnabled':
if (args[0]) {
// Create trayIcon icon
tray.create(trayConfig);
} else {
tray.destroy();
}
store.set('minimizeToTray', args[0]);
break;
case 'getAutoHideMenuBarEnabled':
ret = global.mainWindow.autoHideMenuBar;
break;
case 'setAutoHideMenuBarEnabled':
store.set('autoHideMenuBar', args[0]);
global.mainWindow.autoHideMenuBar = Boolean(args[0]);
global.mainWindow.setMenuBarVisibility(!args[0]);
break;
case 'getDisableHardwareAcceleration':
ret = store.get('disableHardwareAcceleration') === true;
break;
case 'setDisableHardwareAcceleration':
store.set('disableHardwareAcceleration', args[0]);
break;
case 'getAppVersion':
ret = app.getVersion();
break;
Expand Down Expand Up @@ -868,7 +898,7 @@ app.enableSandbox();
app.commandLine.appendSwitch('disable-features', 'HardwareMediaKeyHandling,MediaSessionService');

// Disable hardware acceleration if the setting has been set.
if (store.get('disableHardwareAcceleration') === true) {
if (store.get('disableHardwareAcceleration', false) === true) {
console.log("Disabling hardware acceleration.");
app.disableHardwareAcceleration();
}
Expand Down

0 comments on commit d3cd2c9

Please sign in to comment.