15 changed files with 394 additions and 108 deletions
@ -0,0 +1,57 @@ |
|||||||
|
|
||||||
|
/** |
||||||
|
* Singleton class for notification dispatching. |
||||||
|
*/ |
||||||
|
Ext.define('Rambox.util.Notifier', { |
||||||
|
|
||||||
|
singleton: true, |
||||||
|
|
||||||
|
constructor: function(config) { |
||||||
|
|
||||||
|
config = config || {}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the notification text depending on the service type. |
||||||
|
* |
||||||
|
* @param view |
||||||
|
* @param count |
||||||
|
* @return {*} |
||||||
|
*/ |
||||||
|
function getNotificationText(view, count) { |
||||||
|
var text; |
||||||
|
switch (Ext.getStore('ServicesList').getById(view.type).get('type')) { |
||||||
|
case 'messaging': |
||||||
|
text = 'You have ' + Ext.util.Format.plural(count, 'new message', 'new messages') + '.'; |
||||||
|
break; |
||||||
|
case 'email': |
||||||
|
text = 'You have ' + Ext.util.Format.plural(count, 'new email', 'new emails') + '.'; |
||||||
|
break; |
||||||
|
default: |
||||||
|
text = 'You have ' + Ext.util.Format.plural(count, 'new activity', 'new activities') + '.'; |
||||||
|
break; |
||||||
|
} |
||||||
|
return text; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Dispatches a notification for a specific service. |
||||||
|
* |
||||||
|
* @param view The view of the service |
||||||
|
* @param {number} count The unread count |
||||||
|
*/ |
||||||
|
this.dispatchNotification = function(view, count) { |
||||||
|
var text = getNotificationText(view, count); |
||||||
|
|
||||||
|
var notification = new Notification(view.record.get('name'), { |
||||||
|
body: text, |
||||||
|
icon: view.tab.icon, |
||||||
|
silent: view.record.get('muted') |
||||||
|
}); |
||||||
|
|
||||||
|
notification.onclick = function() { |
||||||
|
require('electron').remote.getCurrentWindow().show(); |
||||||
|
Ext.cq1('app-main').setActiveTab(view); |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
@ -0,0 +1,75 @@ |
|||||||
|
/** |
||||||
|
* Singleton class to handle the global unread counter. |
||||||
|
*/ |
||||||
|
Ext.define('Rambox.util.UnreadCounter', { |
||||||
|
|
||||||
|
singleton: true, |
||||||
|
|
||||||
|
constructor: function(config) { |
||||||
|
|
||||||
|
config = config || {}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Map for storing the global unread count. |
||||||
|
* service id -> unread count |
||||||
|
* |
||||||
|
* @type {Map} |
||||||
|
*/ |
||||||
|
var unreadCountByService = new Map(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Holds the global unread count for internal usage. |
||||||
|
* |
||||||
|
* @type {number} |
||||||
|
*/ |
||||||
|
var totalUnreadCount = 0; |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets the application's unread count to tracked unread count. |
||||||
|
*/ |
||||||
|
function updateAppUnreadCounter() { |
||||||
|
Rambox.app.setTotalNotifications(totalUnreadCount); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the global unread count. |
||||||
|
* |
||||||
|
* @return {number} |
||||||
|
*/ |
||||||
|
this.getTotalUnreadCount = function() { |
||||||
|
return totalUnreadCount; |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Sets the global unread count for a specific service. |
||||||
|
* |
||||||
|
* @param {*} id Id of the service to set the global unread count for. |
||||||
|
* @param {number} unreadCount The global unread count for the service. |
||||||
|
*/ |
||||||
|
this.setUnreadCountForService = function(id, unreadCount) { |
||||||
|
unreadCount = parseInt(unreadCount, 10); |
||||||
|
|
||||||
|
if (unreadCountByService.has(id)) { |
||||||
|
totalUnreadCount -= unreadCountByService.get(id); |
||||||
|
} |
||||||
|
totalUnreadCount += unreadCount; |
||||||
|
unreadCountByService.set(id, unreadCount); |
||||||
|
|
||||||
|
updateAppUnreadCounter(); |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Clears the global unread count for a specific service. |
||||||
|
* |
||||||
|
* @param {*} id Id of the service to clear the global unread count for. |
||||||
|
*/ |
||||||
|
this.clearUnreadCountForService = function(id) { |
||||||
|
if (unreadCountByService.has(id)) { |
||||||
|
totalUnreadCount -= unreadCountByService.get(id); |
||||||
|
} |
||||||
|
unreadCountByService['delete'](id); |
||||||
|
|
||||||
|
updateAppUnreadCounter(); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
@ -0,0 +1,34 @@ |
|||||||
|
/** |
||||||
|
* Per default scrolling the tab bar moves the tabs 20 pixels. |
||||||
|
* To improve the usability of the tab bar this value is increased for Rambox. |
||||||
|
* Also animations are enabled, so the user understands what's going on. |
||||||
|
*/ |
||||||
|
Ext.define('Rambox.overrides.layout.container.boxOverflow.Scroller', { |
||||||
|
override: 'Ext.layout.container.boxOverflow.Scroller', |
||||||
|
|
||||||
|
scrollIncrement: 250, |
||||||
|
wheelIncrement: 50, |
||||||
|
|
||||||
|
animateScroll: true, |
||||||
|
scrollDuration: 250, |
||||||
|
|
||||||
|
/** |
||||||
|
* In difference to the overridden function this one enables scroll animations. |
||||||
|
* |
||||||
|
* @private |
||||||
|
* Scrolls to the left by the configured amount |
||||||
|
*/ |
||||||
|
scrollLeft: function() { |
||||||
|
this.scrollBy(-this.scrollIncrement); |
||||||
|
}, |
||||||
|
|
||||||
|
/** |
||||||
|
* In difference to the overridden function this one enables scroll animations. |
||||||
|
* |
||||||
|
* @private |
||||||
|
* Scrolls to the right by the configured amount |
||||||
|
*/ |
||||||
|
scrollRight: function() { |
||||||
|
this.scrollBy(this.scrollIncrement); |
||||||
|
} |
||||||
|
}); |
After Width: | Height: | Size: 3.2 KiB |
Loading…
Reference in new issue