From 88126c45e7e545a89b2db086959e01625af96075 Mon Sep 17 00:00:00 2001 From: Ramiro Saenz Date: Thu, 1 Sep 2016 19:50:08 -0300 Subject: [PATCH] Improve and fix unread badges --- app/store/ServicesList.js | 2 ++ app/ux/WebView.js | 28 +--------------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/app/store/ServicesList.js b/app/store/ServicesList.js index 355e7db5..d7d2872b 100644 --- a/app/store/ServicesList.js +++ b/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);' }, { diff --git a/app/ux/WebView.js b/app/ux/WebView.js index 2febbd40..d4286955 100644 --- a/app/ux/WebView.js +++ b/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 ) {