Browse Source

Improve and fix unread badges

pull/291/merge
Ramiro Saenz 9 years ago
parent
commit
88126c45e7
  1. 2
      app/store/ServicesList.js
  2. 28
      app/ux/WebView.js

2
app/store/ServicesList.js

@ -53,6 +53,7 @@ Ext.define('Rambox.store.ServicesList', {
,description: 'Instantly reach the people in your life for free. Messenger is just like texting, but you don\'t have to pay for every message.'
,url: 'https://www.messenger.com/login/'
,type: 'messaging'
,titleBlink: true
,note: 'To enable desktop notifications, you have to go to Options inside Messenger.'
},
{
@ -71,6 +72,7 @@ Ext.define('Rambox.store.ServicesList', {
,description: 'Hangouts bring conversations to life with photos, emoji, and even group video calls for free. Connect with friends across computers, Android, and Apple devices.'
,url: 'https://hangouts.google.com/'
,type: 'messaging'
,titleBlink: true
,js_unread: 'function checkUnread(){updateBadge(document.getElementById("hangout-landing-chat").lastChild.contentWindow.document.body.getElementsByClassName("ee").length)}function updateBadge(e){e>=1?document.title="("+e+") "+originalTitle:document.title=originalTitle}var originalTitle=document.title;setInterval(checkUnread,3000);'
},
{

28
app/ux/WebView.js

@ -10,7 +10,6 @@ Ext.define('Rambox.ux.WebView',{
]
// private
,notifications: 0
,zoomLevel: 0
// CONFIG
@ -233,32 +232,7 @@ Ext.define('Rambox.ux.WebView',{
count = count === '•' ? count : Ext.isArray(count.match(/\d+/g)) ? count.match(/\d+/g).join("") : count.match(/\d+/g); // Some services have special characters. Example: (•)
count = count === null ? '0' : count;
var formattedCount = Rambox.util.Format.formatNumber(count);
switch ( me.type ) {
case 'messenger':
if ( count !== me.notifications && count > 0 ) {
me.notifications = count;
}
if ( count || e.title === 'Messenger' ) {
me.tab.setBadgeText(formattedCount);
}
if ( e.title === 'Messenger' ) me.notifications = 0;
break;
case 'hangouts':
if ( count !== me.notifications && count > 0 ) {
me.notifications = count;
}
if ( count || e.title === 'Google Hangouts' ) {
me.tab.setBadgeText(formattedCount);
}
if ( e.title === 'Google Hangouts' ) me.notifications = 0;
break;
default:
me.tab.setBadgeText(formattedCount);
me.notifications = count;
break;
}
me.tab.setBadgeText(Rambox.util.Format.formatNumber(count));
});
webview.addEventListener('did-get-redirect-request', function( e ) {

Loading…
Cancel
Save