Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ require('crash-reporter').start();
var Menu = require('menu');
var Tray = require('tray');
var BrowserWindow = require('browser-window');
var AutoLaunch = require('auto-launch')
, start = new AutoLaunch({
name: 'Gitify',
path: process.execPath.match(/.*?\.app/)[0]
});

var iconIdle = path.join(__dirname, 'images', 'tray-idleTemplate.png');
var iconActive = path.join(__dirname, 'images', 'tray-active.png');
Expand Down Expand Up @@ -94,6 +99,14 @@ app.on('ready', function(){
}
});

ipc.on('startup-enable', function() {
start.enable();
});

ipc.on('startup-disable', function() {
start.disable();
});

ipc.on('app-quit', function() {
app.quit();
});
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
},
"homepage": "https://github.com/ekonstantinidis/gitify",
"dependencies": {
"auto-launch": "^0.1.18",
"bootstrap": "=3.3.4",
"browserify": "=10.2.1",
"font-awesome": "=4.3.0",
Expand Down
11 changes: 10 additions & 1 deletion src/js/components/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ var SettingsPage = React.createClass({
return {
participating: settings.participating,
playSound: settings.playSound,
showNotifications: settings.showNotifications
showNotifications: settings.showNotifications,
openAtStartup: settings.openAtStartup
};
},

Expand Down Expand Up @@ -51,6 +52,14 @@ var SettingsPage = React.createClass({
onChange={this.toggleSetting.bind(this, 'showNotifications')} />
</div>
</div>
<div className='row'>
<div className='col-xs-8'>Open at startup</div>
<div className='col-xs-4'>
<Toggle
defaultChecked={this.state.openAtStartup}
onChange={this.toggleSetting.bind(this, 'openAtStartup')} />
</div>
</div>
<div className='row'>
<button
className='btn btn-block btn-danger btn-close'
Expand Down
15 changes: 14 additions & 1 deletion src/js/stores/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var SettingsStore = Reflux.createStore({
settings = {
participating: false,
playSound: true,
showNotifications: true
showNotifications: true,
openAtStartup: false
};
}

Expand All @@ -28,6 +29,9 @@ var SettingsStore = Reflux.createStore({
if (!settings.showNotifications) {
settings.showNotifications = true;
}
if (!settings.openAtStartup) {
settings.openAtStartup = false;
}

this._settings = settings;
window.localStorage.setItem('settings', JSON.stringify(this._settings));
Expand All @@ -41,6 +45,15 @@ var SettingsStore = Reflux.createStore({
this._settings[setting] = value;
window.localStorage.setItem('settings', JSON.stringify(this._settings));
this.trigger(this._settings);
if(setting == 'openAtStartup') {
this.handleStartup(value);
}
},

handleStartup: function (value) {
var ipc = window.require('ipc');
var method = (value) ? 'startup-enable' : 'startup-disable';
ipc.send(method);
}

});
Expand Down