Skip to content

Commit 203b2c2

Browse files
Merge pull request #10 from ekonstantinidis/reopen-window-login
Reopen window on login
2 parents cc715ec + f9567e6 commit 203b2c2

File tree

5 files changed

+29
-30
lines changed

5 files changed

+29
-30
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ npm-debug.log
33

44
build/
55
node_modules/
6+
Gitify.app/

main.js

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var iconGreen = path.join('./images/', 'github-tray-green.png');
1313

1414
app.on('ready', function(){
1515
appIcon = new Tray(iconPlain);
16+
initWindow();
1617

1718
appIcon.on('clicked', function clicked (e, bounds) {
1819
if (appIcon.window && appIcon.window.isVisible()) {
@@ -22,47 +23,41 @@ app.on('ready', function(){
2223
}
2324
});
2425

25-
function showWindow (bounds) {
26-
var options = {
27-
x: bounds.x - 200 + (bounds.width / 2),
28-
y: bounds.y,
26+
function initWindow () {
27+
var defaults = {
2928
width: 400,
3029
height: 350,
31-
index: path.join('./', 'index.html')
32-
};
33-
34-
if (appIcon.window) {
35-
// BrowserWindow exists - Do not Create
36-
appIcon.window.show();
37-
} else {
38-
initWindow(options);
39-
}
40-
}
41-
42-
function initWindow (options) {
43-
// Create BrowserWindow
44-
var defaults = {
45-
width: options.width,
46-
height: options.height,
47-
show: true,
30+
show: false,
4831
frame: false,
4932
resizable: false,
5033
'standard-window': false
5134
};
5235

5336
appIcon.window = new BrowserWindow(defaults);
54-
appIcon.window.setPosition(options.x, options.y);
55-
appIcon.window.on('blur', hideWindow);
5637
appIcon.window.loadUrl('file://' + __dirname + '/index.html');
38+
appIcon.window.on('blur', hideWindow);
39+
}
40+
41+
function showWindow (bounds) {
42+
var options = {
43+
x: bounds.x - 200 + (bounds.width / 2),
44+
y: bounds.y,
45+
index: path.join('./', 'index.html')
46+
};
47+
48+
appIcon.window.setPosition(options.x, options.y);
49+
appIcon.window.show();
5750
}
5851

5952
function hideWindow () {
6053
if (!appIcon.window) return;
61-
appIcon.emit('hide');
6254
appIcon.window.hide();
63-
appIcon.emit('after-hide');
6455
}
6556

57+
ipc.on('reopen-window', function(event) {
58+
appIcon.window.show();
59+
});
60+
6661
ipc.on('update-icon', function(event, arg) {
6762
var icon;
6863
if (arg == "IconGreen") {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"watch-js": "watchify -t reactify src/js/app.js -o build/js/app.js -v",
1010
"watch": "grunt build && npm build && npm run watch-js | grunt watch",
1111
"start": "electron .",
12-
"dist": "rm -rf GithubNotfier.app/ && electron-packager . GithubNotfier --platform=darwin --arch=x64 --version=0.26.0 --prune --ignore=.git --ignore=src",
12+
"dist": "rm -rf Gitify.app/ && electron-packager . Gitify --platform=darwin --arch=x64 --version=0.26.1 --prune --ignore=src",
1313
"test": "jsxhint --reporter node_modules/jshint-stylish/stylish.js 'src/**/*.js', 'index.js' --exclude 'Gruntfile.js'"
1414
},
1515
"repository": {
@@ -44,8 +44,8 @@
4444
"watchify": "=3.2.1"
4545
},
4646
"devDependencies": {
47-
"electron-packager": "=4.1.0",
48-
"electron-prebuilt": "=0.26.0",
47+
"electron-packager": "=4.1.1",
48+
"electron-prebuilt": "=0.26.1",
4949
"grunt": "=0.4.5",
5050
"grunt-contrib-clean": "=0.6.0",
5151
"grunt-contrib-copy": "=0.8.0",

src/js/components/login.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var remote = window.require('remote');
2+
var ipc = window.require('ipc');
23
var BrowserWindow = remote.require('browser-window');
34

45
var React = require('react');
@@ -24,11 +25,10 @@ var Login = React.createClass({
2425
};
2526

2627
//Build the OAuth consent page URL
27-
var authWindow = new BrowserWindow({ width: 800, height: 600, show: false, 'node-integration': false });
28+
var authWindow = new BrowserWindow({ width: 800, height: 600, show: true, 'node-integration': false });
2829
var githubUrl = 'https://github.com/login/oauth/authorize?';
2930
var authUrl = githubUrl + 'client_id=' + options.client_id + '&scope=' + options.scope;
3031
authWindow.loadUrl(authUrl);
31-
authWindow.show();
3232

3333
authWindow.webContents.on('did-get-redirect-request', function(event, oldUrl, newUrl) {
3434

@@ -71,6 +71,7 @@ var Login = React.createClass({
7171
// Success - Do Something.
7272
Actions.login(response.body.access_token);
7373
self.context.router.transitionTo('notifications');
74+
ipc.sendChannel('reopen-window');
7475
} else {
7576
// Error - Show messages.
7677
console.log(err);

src/js/components/navigation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var React = require('react');
22
var Reflux = require('Reflux');
3+
var ipc = window.require('ipc');
34

45
var Actions = require('../actions/actions');
56
var AuthStore = require('../stores/auth');
@@ -44,6 +45,7 @@ var Navigation = React.createClass({
4445
logOut: function () {
4546
Actions.logout();
4647
this.context.router.transitionTo('login');
48+
ipc.sendChannel('update-icon', "IconPlain");
4749
},
4850

4951
render: function () {

0 commit comments

Comments
 (0)