From 47c3419c0ea66caa85e7c5308f87671e03db27c5 Mon Sep 17 00:00:00 2001 From: Aviral Dasgupta Date: Wed, 16 Mar 2016 05:28:31 +0530 Subject: [PATCH 1/2] Display sync status in favicon and title Signed-off-by: Aviral Dasgupta --- src/components/structures/MatrixChat.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index df27d38172..fbb837064c 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -599,7 +599,7 @@ module.exports = React.createClass({ var cli = MatrixClientPeg.get(); var self = this; cli.on('sync', function(state, prevState) { - self.updateFavicon(); + self.updateFavicon(state, prevState); if (state === "SYNCING" && prevState === "SYNCING") { return; } @@ -887,7 +887,7 @@ module.exports = React.createClass({ }); }, - updateFavicon: function() { + updateFavicon: function(state, prevState) { var notifCount = 0; var rooms = MatrixClientPeg.get().getRooms(); @@ -907,6 +907,11 @@ module.exports = React.createClass({ console.warn("Failed to set badge count: "+e.message); } document.title = "Vector"+(notifCount > 0 ? " ["+notifCount+"]" : ""); + + if(state === "ERROR") { + this.favicon.badge("×"); + document.title = "Vector [ERROR]"; + } }, onUserSettingsClose: function() { From b47ea1ca4bf96eae5c1caacde20404257d0fd24b Mon Sep 17 00:00:00 2001 From: Aviral Dasgupta Date: Wed, 16 Mar 2016 06:32:49 +0530 Subject: [PATCH 2/2] Color for sync status, less scary message --- src/components/structures/MatrixChat.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index fbb837064c..52278c87f4 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -902,16 +902,21 @@ module.exports = React.createClass({ // This needs to be in in a try block as it will throw // if there are more than 100 badge count changes in // its internal queue - this.favicon.badge(notifCount); + var bgColor = "#0d0", + notif = notifCount; + + if(state === "ERROR") { + notif = notif || "×"; + bgColor = "#d00"; + } + + this.favicon.badge(notif, { + bgColor: bgColor + }); } catch (e) { console.warn("Failed to set badge count: "+e.message); } - document.title = "Vector"+(notifCount > 0 ? " ["+notifCount+"]" : ""); - - if(state === "ERROR") { - this.favicon.badge("×"); - document.title = "Vector [ERROR]"; - } + document.title = `Vector ${state === "ERROR" ? " [offline]" : ""}${notifCount > 0 ? ` [${notifCount}]` : ""}`; }, onUserSettingsClose: function() {