auto-launch support, ux =checkbox in UserSettings[Electron]
settings are sorta generic, probably reusable for proxy settings Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/4012/head
parent
7d59742a22
commit
a98792b05e
|
@ -6,6 +6,7 @@
|
|||
"description": "A feature-rich client for Matrix.org",
|
||||
"author": "Vector Creations Ltd.",
|
||||
"dependencies": {
|
||||
"auto-launch": "^5.0.1",
|
||||
"electron-window-state": "^4.1.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ const check_squirrel_hooks = require('./squirrelhooks');
|
|||
if (check_squirrel_hooks()) return;
|
||||
|
||||
const electron = require('electron');
|
||||
const AutoLaunch = require('auto-launch');
|
||||
const url = require('url');
|
||||
|
||||
const tray = require('./tray');
|
||||
|
@ -202,6 +203,44 @@ if (shouldQuit) {
|
|||
electron.app.quit()
|
||||
}
|
||||
|
||||
|
||||
const launcher = new AutoLaunch({
|
||||
name: vectorConfig.brand || 'Riot',
|
||||
isHidden: true,
|
||||
});
|
||||
|
||||
const settings = {
|
||||
'auto-launch': {
|
||||
get: launcher.isEnabled,
|
||||
set: function(bool) {
|
||||
if (bool) {
|
||||
return launcher.enable();
|
||||
} else {
|
||||
return launcher.disable();
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
electron.ipcMain.on('settings_get', async function(ev) {
|
||||
const data = {};
|
||||
|
||||
try {
|
||||
await Promise.all(Object.keys(settings).map(async function (setting) {
|
||||
data[setting] = await settings[setting].get();
|
||||
}));
|
||||
|
||||
ev.sender.send('settings', data);
|
||||
} catch(e) { console.error(e); }
|
||||
});
|
||||
|
||||
electron.ipcMain.on('settings_set', function(ev, key, value) {
|
||||
console.log(key, value);
|
||||
if (settings[key] && settings[key].set) {
|
||||
settings[key].set(value);
|
||||
}
|
||||
});
|
||||
|
||||
electron.app.on('ready', () => {
|
||||
if (vectorConfig.update_base_url) {
|
||||
console.log("Starting auto update with base URL: " + vectorConfig.update_base_url);
|
||||
|
|
|
@ -138,6 +138,8 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
return null;
|
||||
}
|
||||
|
||||
isElectron(): boolean { return true; }
|
||||
|
||||
requestNotificationPermission(): Promise<string> {
|
||||
return q('granted');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue