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>
This commit is contained in:
Michael Telatynski 2017-05-24 15:52:08 +01:00
parent 7d59742a22
commit a98792b05e
3 changed files with 42 additions and 0 deletions

View File

@ -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"
}
}

View File

@ -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);

View File

@ -138,6 +138,8 @@ export default class ElectronPlatform extends VectorBasePlatform {
return null;
}
isElectron(): boolean { return true; }
requestNotificationPermission(): Promise<string> {
return q('granted');
}