Commit 3219cbf8 authored by Tasso Evangelista's avatar Tasso Evangelista

Add option to show window when new message is received

Closes #213
parent 7b3d2ace
......@@ -71,6 +71,7 @@
"Server list": "Server list",
"Share_Your_Screen": "Share Your Screen",
"Show": "Show",
"Show window on unread messages": "Show window on unread messages",
"Spelling_languages": "Spelling languages",
"Timeout_trying_to_connect": "Timeout trying to connect",
"Toggle &DevTools": "Toggle &DevTools",
......
......@@ -70,6 +70,7 @@
"Services": "Serviços",
"Share_Your_Screen": "Compartilhe sua Tela",
"Show": "Mostrar",
"Show window on unread messages": "Exibir janela quando há mensagens não lidas",
"Spelling_languages": "Línguas Suportadas",
"Timeout_trying_to_connect": "Tempo Esgotado ao Carregar",
"Toggle &DevTools": "Alternar &DevTools",
......
......@@ -153,6 +153,12 @@ const createMenuTemplate = (state, actions) => ([
},
] : []),
...(process.platform !== 'darwin' ? [
{
label: i18n.__('Show window on unread messages'),
type: 'checkbox',
checked: state.showWindowOnUnreadChanged,
click: actions.toggleShowWindowOnUnreadChanged,
},
{
label: i18n.__('Menu bar'),
type: 'checkbox',
......@@ -330,10 +336,17 @@ const actions = {
actions.update();
},
toggleShowWindowOnUnreadChanged() {
const previousValue = localStorage.getItem('showWindowOnUnreadChanged') === 'true';
const newValue = !previousValue;
localStorage.setItem('showWindowOnUnreadChanged', JSON.stringify(newValue));
actions.update();
},
toggleMenuBar() {
const hadMenuBar = localStorage.getItem('autohideMenu') !== 'true';
const hasMenuBar = !hadMenuBar;
localStorage.setItem('autohideMenu', JSON.stringify(!hasMenuBar));
const previousValue = localStorage.getItem('autohideMenu') !== 'true';
const newValue = !previousValue;
localStorage.setItem('autohideMenu', JSON.stringify(!newValue));
actions.update();
},
......@@ -370,6 +383,7 @@ const actions = {
currentServerUrl: servers.active,
trayIcon: localStorage.getItem('hideTray') !== 'true',
fullScreen: getCurrentWindow().isFullScreen(),
showWindowOnUnreadChanged: localStorage.getItem('showWindowOnUnreadChanged') === 'true',
menuBar: localStorage.getItem('autohideMenu') !== 'true',
serverList: localStorage.getItem('sidebar-closed') !== 'true',
};
......
/* globals $ */
import { ipcRenderer } from 'electron';
import { remote, ipcRenderer } from 'electron';
import i18n from '../i18n/index.js';
import servers from './servers';
import sidebar from './sidebar';
......@@ -188,3 +188,14 @@ export const start = function() {
window.addEventListener('focus', function() {
webview.focusActive();
});
webview.on('ipc-message-unread-changed', (hostUrl, [count]) => {
if (typeof count === 'number' && localStorage.getItem('showWindowOnUnreadChanged') === 'true') {
const mainWindow = remote.getCurrentWindow();
if (!mainWindow.isFocused()) {
mainWindow.once('focus', () => mainWindow.flashFrame(false));
mainWindow.showInactive();
mainWindow.flashFrame(true);
}
}
});
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