Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Added a force quit option to the app, if this is set, the application
will quit. Otherwise it'll just hide.
- Fixed bug in windows, where you had to triple-click the tray icon show
the app
  • Loading branch information
floriangoeldi committed Feb 28, 2016
1 parent ebabbaf commit 83eb0a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions app/scripts/menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ if (process.platform === 'darwin') {
label: 'Quit',
accelerator: 'Command+Q',
click: function() {
remote.app.forceQuit = true;
app.quit();
}
}
Expand Down Expand Up @@ -169,6 +170,7 @@ if (process.platform === 'darwin') {
label: 'Quit',
accelerator: 'Ctrl+Q',
click: function() {
remote.app.forceQuit = true;
app.quit();
}
}
Expand Down
21 changes: 14 additions & 7 deletions app/scripts/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,21 @@ function createAppTray(mainWindow) {
}, {
label: 'Quit',
click: function() {
remote.app.forceQuit = true;
doQuit();
}
}]);
_tray.setToolTip('Rocket.Chat');
_tray.setContextMenu(contextMenu);

if (process.platform === 'darwin') {
_tray.on('double-clicked', function() {
if (process.platform === 'darwin' || process.platform == 'win32') {
_tray.on('double-click', function() {
toggleShowMainWindow();
});
} else {
let dblClickDelay = 500,
dblClickTimeoutFct = null;
_tray.on('clicked', function() {
_tray.on('click', function() {
if (!dblClickTimeoutFct) {
dblClickTimeoutFct = setTimeout(function() {
// Single click, do nothing for now
Expand Down Expand Up @@ -97,7 +98,6 @@ function showTrayAlert(showAlert, title) {
_tray.setImage(_iconTrayAlert);
if (process.platform === 'darwin') {
_tray.setTitle(title);
// _tray.setTitle(title);
}
} else {
_tray.setImage(_iconTray);
Expand Down Expand Up @@ -145,9 +145,16 @@ bindOnQuit(function() {
remote.app.quit();
});

window.addEventListener('beforeunload', function() {
destroy();
});
// Closes or hides the client
window.onbeforeunload = function(e) {
if(!remote.app.forceQuit) {
showMainWindow(false);
return false;
}
else {
destroy();
}
}

export default {
createAppTray: createAppTray,
Expand Down

0 comments on commit 83eb0a4

Please sign in to comment.