Adds a setting to launch the app on system login
This commit is contained in:
@@ -6,6 +6,7 @@ const settings = require('../common/settings');
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const ReactDOM = require('react-dom');
|
const ReactDOM = require('react-dom');
|
||||||
const ReactBootstrap = require('react-bootstrap');
|
const ReactBootstrap = require('react-bootstrap');
|
||||||
|
var AutoLaunch = require('auto-launch');
|
||||||
|
|
||||||
const Grid = ReactBootstrap.Grid;
|
const Grid = ReactBootstrap.Grid;
|
||||||
const Row = ReactBootstrap.Row;
|
const Row = ReactBootstrap.Row;
|
||||||
@@ -16,6 +17,10 @@ const ListGroup = ReactBootstrap.ListGroup;
|
|||||||
const ListGroupItem = ReactBootstrap.ListGroupItem;
|
const ListGroupItem = ReactBootstrap.ListGroupItem;
|
||||||
const Glyphicon = ReactBootstrap.Glyphicon;
|
const Glyphicon = ReactBootstrap.Glyphicon;
|
||||||
|
|
||||||
|
var appLauncher = new AutoLaunch({
|
||||||
|
name: 'Mattermost'
|
||||||
|
});
|
||||||
|
|
||||||
function backToIndex() {
|
function backToIndex() {
|
||||||
remote.getCurrentWindow().loadURL('file://' + __dirname + '/index.html');
|
remote.getCurrentWindow().loadURL('file://' + __dirname + '/index.html');
|
||||||
}
|
}
|
||||||
@@ -35,6 +40,16 @@ var SettingsPage = React.createClass({
|
|||||||
|
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
|
componentDidMount: function() {
|
||||||
|
if (process.platform === 'win32' || process.platform === 'linux') {
|
||||||
|
var self = this;
|
||||||
|
appLauncher.isEnabled().then(function(enabled) {
|
||||||
|
self.setState({
|
||||||
|
autostart: enabled
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
handleTeamsChange: function(teams) {
|
handleTeamsChange: function(teams) {
|
||||||
this.setState({
|
this.setState({
|
||||||
teams: teams
|
teams: teams
|
||||||
@@ -56,6 +71,15 @@ var SettingsPage = React.createClass({
|
|||||||
var currentWindow = remote.getCurrentWindow();
|
var currentWindow = remote.getCurrentWindow();
|
||||||
currentWindow.setAutoHideMenuBar(config.hideMenuBar);
|
currentWindow.setAutoHideMenuBar(config.hideMenuBar);
|
||||||
currentWindow.setMenuBarVisibility(!config.hideMenuBar);
|
currentWindow.setMenuBarVisibility(!config.hideMenuBar);
|
||||||
|
|
||||||
|
var autostart = this.state.autostart;
|
||||||
|
appLauncher.isEnabled().then(function(enabled) {
|
||||||
|
if (enabled && !autostart) {
|
||||||
|
appLauncher.disable();
|
||||||
|
} else if (!enabled && autostart) {
|
||||||
|
appLauncher.enable();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof toIndex == 'undefined' || toIndex) {
|
if (typeof toIndex == 'undefined' || toIndex) {
|
||||||
@@ -85,6 +109,11 @@ var SettingsPage = React.createClass({
|
|||||||
trayIconTheme: this.refs.trayIconTheme.getValue()
|
trayIconTheme: this.refs.trayIconTheme.getValue()
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
handleChangeAutoStart: function() {
|
||||||
|
this.setState({
|
||||||
|
autostart: this.refs.autostart.getChecked()
|
||||||
|
});
|
||||||
|
},
|
||||||
handleShowTeamForm: function() {
|
handleShowTeamForm: function() {
|
||||||
if (!this.state.showAddTeamForm) {
|
if (!this.state.showAddTeamForm) {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -127,6 +156,10 @@ var SettingsPage = React.createClass({
|
|||||||
}
|
}
|
||||||
options.push(<Input key="inputDisableWebSecurity" ref="disablewebsecurity" type="checkbox" label="Allow mixed content (Enabling allows both secure and insecure content, images and scripts to render and execute. Disabling allows only secure content.)"
|
options.push(<Input key="inputDisableWebSecurity" ref="disablewebsecurity" type="checkbox" label="Allow mixed content (Enabling allows both secure and insecure content, images and scripts to render and execute. Disabling allows only secure content.)"
|
||||||
checked={ this.state.disablewebsecurity } onChange={ this.handleChangeDisableWebSecurity } />);
|
checked={ this.state.disablewebsecurity } onChange={ this.handleChangeDisableWebSecurity } />);
|
||||||
|
//OSX has an option in the tray, to set the app to autostart, so we choose to not support this option for OSX
|
||||||
|
if (process.platform === 'win32' || process.platform === 'linux') {
|
||||||
|
options.push(<Input key="inputAutoStart" ref="autostart" type="checkbox" label="Start app on login." checked={ this.state.autostart } onChange={ this.handleChangeAutoStart } />);
|
||||||
|
}
|
||||||
var options_row = (options.length > 0) ? (
|
var options_row = (options.length > 0) ? (
|
||||||
<Row>
|
<Row>
|
||||||
<Col md={ 12 }>
|
<Col md={ 12 }>
|
||||||
|
16
src/main.js
16
src/main.js
@@ -3,7 +3,21 @@
|
|||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
const app = electron.app; // Module to control application life.
|
const app = electron.app; // Module to control application life.
|
||||||
|
|
||||||
if (require('electron-squirrel-startup')) app.quit();
|
if (process.platform === 'win32') {
|
||||||
|
var cmd = process.argv[1];
|
||||||
|
if (cmd === '--squirrel-uninstall') {
|
||||||
|
var AutoLaunch = require('auto-launch');
|
||||||
|
var appLauncher = new AutoLaunch({
|
||||||
|
name: 'Mattermost'
|
||||||
|
});
|
||||||
|
appLauncher.isEnabled().then(function(enabled) {
|
||||||
|
if (enabled)
|
||||||
|
appLauncher.disable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require('electron-squirrel-startup');
|
||||||
|
|
||||||
const BrowserWindow = electron.BrowserWindow; // Module to create native browser window.
|
const BrowserWindow = electron.BrowserWindow; // Module to create native browser window.
|
||||||
const Menu = electron.Menu;
|
const Menu = electron.Menu;
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
"electron-connect": "^0.3.3"
|
"electron-connect": "^0.3.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"auto-launch": "^2.0.1",
|
||||||
"bootstrap": "^3.3.6",
|
"bootstrap": "^3.3.6",
|
||||||
"os-locale": "^1.4.0",
|
"os-locale": "^1.4.0",
|
||||||
"react": "^15.0.1",
|
"react": "^15.0.1",
|
||||||
|
Reference in New Issue
Block a user