Browse Source

Setting "•" as unread count now possible from js_unread, updated Slack js_unread to do this. TODO add for other services with "•".

pull/1759/head
Jakob Struye 7 years ago
parent
commit
481da04805
  1. 2
      app/store/ServicesList.js
  2. 5
      app/ux/WebView.js

2
app/store/ServicesList.js

@ -37,7 +37,7 @@ Ext.define('Rambox.store.ServicesList', {
,description: locale['services[1]'] ,description: locale['services[1]']
,url: 'https://___.slack.com/' ,url: 'https://___.slack.com/'
,type: 'messaging' ,type: 'messaging'
,js_unread: 'function checkUnread(){var e=$(".p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)").length,a=0;$(".p-channel_sidebar__badge").each(function(){a+=isNaN(parseInt($(this).html()))?0:parseInt($(this).html())}),updateBadge(e,a)}function updateBadge(e,a){var n=a>0?"("+a+") ":e>0?"(•) ":"";document.title=n+originalTitle}var originalTitle=document.title;setInterval(checkUnread,3e3);' ,js_unread: 'function checkUnread(){var e=$(".p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)").length,n=0;$(".p-channel_sidebar__badge").each(function(){n+=isNaN(parseInt($(this).html()))?0:parseInt($(this).html())}),count=0<n?n:0<e?"•":0,updateBadge(count)}function updateBadge(e){1<=e||"•"===e?rambox.setUnreadCount(e):rambox.clearUnreadCount();}setInterval(checkUnread,3e3);'
}, },
{ {
id: 'noysi' id: 'noysi'

5
app/ux/WebView.js

@ -477,14 +477,15 @@ Ext.define('Rambox.ux.WebView',{
/** /**
* Handles 'rambox.setUnreadCount' messages. * Handles 'rambox.setUnreadCount' messages.
* Sets the badge text if the event contains an integer as first argument. * Sets the badge text if the event contains an integer
* or a '•' (indicating non-zero but unknown number of unreads) as first argument.
* *
* @param event * @param event
*/ */
function handleSetUnreadCount(event) { function handleSetUnreadCount(event) {
if (Array.isArray(event.args) === true && event.args.length > 0) { if (Array.isArray(event.args) === true && event.args.length > 0) {
var count = event.args[0]; var count = event.args[0];
if (count === parseInt(count, 10)) { if (count === parseInt(count, 10) || "•" === count) {
me.setUnreadCount(count); me.setUnreadCount(count);
} }
} }

Loading…
Cancel
Save