Browse Source

Show Rambox window and activate service tab on notification click

Fixes #34
pull/594/merge
Ramiro Saenz 8 years ago
parent
commit
90cb5ea95d
  1. 9
      app/ux/WebView.js
  2. 18
      resources/js/rambox-service-api.js

9
app/ux/WebView.js

@ -298,8 +298,8 @@ Ext.define('Rambox.ux.WebView',{
case 'rambox.clearUnreadCount': case 'rambox.clearUnreadCount':
handleClearUnreadCount(event); handleClearUnreadCount(event);
break; break;
case 'rambox.showNotification': case 'rambox.showWindowAndActivateTab':
showNotification(event); showWindowAndActivateTab(event);
break; break;
} }
@ -329,8 +329,9 @@ Ext.define('Rambox.ux.WebView',{
} }
} }
function showNotification(event) { function showWindowAndActivateTab(event) {
console.log('showNotification', event); require('electron').remote.getCurrentWindow().show();
Ext.cq1('app-main').setActiveTab(me);
} }
}); });

18
resources/js/rambox-service-api.js

@ -26,3 +26,21 @@ window.rambox.setUnreadCount = function(count) {
window.rambox.clearUnreadCount = function() { window.rambox.clearUnreadCount = function() {
ipcRenderer.sendToHost('rambox.clearUnreadCount'); ipcRenderer.sendToHost('rambox.clearUnreadCount');
} }
/**
* Override to add notification click event to display Rambox window and activate service tab
*/
var NativeNotification = Notification;
Notification = function(title, options) {
var notification = new NativeNotification(title, options);
notification.addEventListener('click', function() {
ipcRenderer.sendToHost('rambox.showWindowAndActivateTab');
});
return notification;
}
Notification.prototype = NativeNotification.prototype;
Notification.permission = NativeNotification.permission;
Notification.requestPermission = NativeNotification.requestPermission.bind(Notification);

Loading…
Cancel
Save