Merge pull request #4030 from vector-im/t3chguy/electron_profiles

basic electron profile support
This commit is contained in:
Matthew Hodgson 2017-06-01 01:33:01 +01:00 committed by GitHub
commit 21cf79bc54
2 changed files with 9 additions and 3 deletions

View File

@ -6,7 +6,8 @@
"description": "A feature-rich client for Matrix.org", "description": "A feature-rich client for Matrix.org",
"author": "Vector Creations Ltd.", "author": "Vector Creations Ltd.",
"dependencies": { "dependencies": {
"electron-window-state": "^4.1.0",
"auto-launch": "^5.0.1", "auto-launch": "^5.0.1",
"electron-window-state": "^4.1.0" "minimist": "^1.2.0"
} }
} }

View File

@ -21,6 +21,7 @@ limitations under the License.
const checkSquirrelHooks = require('./squirrelhooks'); const checkSquirrelHooks = require('./squirrelhooks');
if (checkSquirrelHooks()) return; if (checkSquirrelHooks()) return;
const argv = require('minimist')(process.argv);
const electron = require('electron'); const electron = require('electron');
const AutoLaunch = require('auto-launch'); const AutoLaunch = require('auto-launch');
@ -30,6 +31,10 @@ const webContentsHandler = require('./webcontents-handler');
const windowStateKeeper = require('electron-window-state'); const windowStateKeeper = require('electron-window-state');
if (argv.profile) {
electron.app.setPath('userData', `${electron.app.getPath('userData')}-${argv.profile}`);
}
let vectorConfig = {}; let vectorConfig = {};
try { try {
vectorConfig = require('../../webapp/config.json'); vectorConfig = require('../../webapp/config.json');
@ -166,7 +171,7 @@ const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirector
if (shouldQuit) { if (shouldQuit) {
console.log('Other instance detected: exiting'); console.log('Other instance detected: exiting');
electron.app.quit(); electron.app.exit();
} }
@ -249,7 +254,7 @@ electron.app.on('ready', () => {
brand: vectorConfig.brand || 'Riot', brand: vectorConfig.brand || 'Riot',
}); });
if (!process.argv.includes('--hidden')) { if (!argv.hidden) {
mainWindow.once('ready-to-show', () => { mainWindow.once('ready-to-show', () => {
mainWindow.show(); mainWindow.show();
}); });