Skip to content

Commit

Permalink
Merge pull request RocketChat#343 from RocketChat/feature/hide-tray
Browse files Browse the repository at this point in the history
Add option to hide tray icon
  • Loading branch information
alexbrazier authored Feb 5, 2017
2 parents 7edf2cd + 033f539 commit a09c60f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/scripts/menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { remote } from 'electron';
import { servers } from './servers';
import { sidebar } from './sidebar';
import { webview } from './webview';
import tray from './tray';
import '../branding/branding.js';

const Menu = remote.Menu;
Expand Down Expand Up @@ -169,7 +170,7 @@ const viewTemplate = [
id: 'toggle'
},
{
label: 'Toggle server list',
label: 'Toggle Server List',
click: function () {
sidebar.toggle();
}
Expand All @@ -190,7 +191,15 @@ const viewTemplate = [
}
];

if (!isMac) {
if (isMac) {
viewTemplate.push({
label: 'Toggle Tray Icon',
click: function () {
tray.toggle();
},
position: 'after=toggle'
});
} else {
viewTemplate.push({
label: 'Toggle Menu Bar',
click: function () {
Expand Down
21 changes: 19 additions & 2 deletions src/scripts/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,25 @@ function showTrayAlert (showAlert, title) {
}
}

createAppTray();
function removeAppTray () {
mainWindow.destroyTray();
}

function toggle () {
if (localStorage.getItem('hideTray') === 'true') {
createAppTray();
localStorage.setItem('hideTray', 'false');
} else {
removeAppTray();
localStorage.setItem('hideTray', 'true');
}
}

if (localStorage.getItem('hideTray') !== 'true') {
createAppTray();
}

export default {
showTrayAlert: showTrayAlert
showTrayAlert,
toggle
};

0 comments on commit a09c60f

Please sign in to comment.