Commit 576f9177 authored by Tasso Evangelista's avatar Tasso Evangelista Committed by GitHub

Merge pull request #899 from RocketChat/feat/optional-status-on-tray

[NEW] Optional status on tray for MacOS
parents 670a27d7 e8e4e7d8
......@@ -8,6 +8,7 @@ const createTemplate = ({
servers = [],
currentServerUrl = null,
showTrayIcon = true,
showUserStatusInTray = true,
showFullScreen = false,
showMenuBar = true,
showServerList = true,
......@@ -151,6 +152,13 @@ const createTemplate = ({
click: () => events.emit('toggle', 'showTrayIcon'),
},
...(process.platform === 'darwin' ? [
{
label: i18n.__('User status in tray'),
type: 'checkbox',
enabled: showTrayIcon,
checked: showTrayIcon && showUserStatusInTray,
click: () => events.emit('toggle', 'showUserStatusInTray'),
},
{
label: i18n.__('Full screen'),
type: 'checkbox',
......
......@@ -95,6 +95,7 @@
"Update_skip_message": "We will notify you when the next update is available\nIf you change your mind you can check for updates from the About menu.",
"Update_skip_remind": "Remind Me Later",
"Update_skip_version": "Skip This Version",
"User status in tray": "User status in tray",
"Validating": "Validating...",
"Version": "Version",
"&View": "&View",
......
......@@ -94,6 +94,7 @@
"Update_skip_message": "Nós iremos lembrá-lo quando a próxima atualização estiver disponível.\nSe você mudar de ideia, pode verificar as atualizações no menu Sobre.",
"Update_skip_remind": "Lembrar Depois",
"Update_skip_version": "Pular Versão",
"User status in tray": "Status do usuário na bandeja",
"Validating": "Validando...",
"Version": "Versão",
"&View": "&Exibir",
......
......@@ -74,6 +74,7 @@ export default () => {
menus.setState({
showTrayIcon: localStorage.getItem('hideTray') !== 'true',
showUserStatusInTray: (localStorage.getItem('showUserStatusInTray') || 'true') === 'true',
showFullScreen: mainWindow.isFullScreen(),
showWindowOnUnreadChanged: localStorage.getItem('showWindowOnUnreadChanged') === 'true',
showMenuBar: localStorage.getItem('autohideMenu') !== 'true',
......@@ -88,6 +89,11 @@ export default () => {
break;
}
case 'showUserStatusInTray': {
tray.toggleStatus();
break;
}
case 'showFullScreen': {
const mainWindow = getCurrentWindow();
mainWindow.setFullScreen(!mainWindow.isFullScreen());
......
......@@ -126,12 +126,24 @@ function createAppTray() {
};
}
let state = {
badge: null,
status: 'online',
};
function showTrayAlert(badge, status = 'online') {
if (mainWindow.tray === null || mainWindow.tray === undefined) {
return;
}
state = {
...state,
badge,
status,
};
const trayDisplayed = localStorage.getItem('hideTray') !== 'true';
const statusDisplayed = (localStorage.getItem('showUserStatusInTray') || 'true') === 'true';
const hasMentions = badge.showAlert && badge.count > 0;
if (!mainWindow.isFocused()) {
......@@ -152,10 +164,10 @@ function showTrayAlert(badge, status = 'online') {
countColor = messageCountColor.white;
}
let trayTitle = `${ statusBullet[status] }`;
if (hasMentions) {
trayTitle = `${ statusBullet[status] } ${ countColor }${ badge.title }`;
}
const trayTitle = [
statusDisplayed && statusBullet[status],
hasMentions && `${ countColor }${ badge.title }`,
].filter(Boolean).join(' ');
remote.app.dock.setBadge(badge.title);
if (trayDisplayed) {
mainWindow.tray.setTitle(trayTitle);
......@@ -179,12 +191,25 @@ function toggle() {
if (localStorage.getItem('hideTray') === 'true') {
createAppTray();
localStorage.setItem('hideTray', 'false');
showTrayAlert(state.badge, state.status);
} else {
removeAppTray();
localStorage.setItem('hideTray', 'true');
}
}
function toggleStatus() {
if (localStorage.getItem('showUserStatusInTray') === 'true') {
localStorage.setItem('showUserStatusInTray', 'false');
} else {
localStorage.setItem('showUserStatusInTray', 'true');
}
if (localStorage.getItem('hideTray') !== 'true') {
showTrayAlert(state.badge, state.status);
}
}
if (localStorage.getItem('hideTray') !== 'true') {
createAppTray();
}
......@@ -192,4 +217,5 @@ if (localStorage.getItem('hideTray') !== 'true') {
export default {
showTrayAlert,
toggle,
toggleStatus,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment