Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Display sync status in favicon and title. #221

Merged
merged 2 commits into from
Mar 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/components/structures/MatrixChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -887,7 +887,7 @@ module.exports = React.createClass({
});
},

updateFavicon: function() {
updateFavicon: function(state, prevState) {
var notifCount = 0;

var rooms = MatrixClientPeg.get().getRooms();
Expand All @@ -902,11 +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+"]" : "");
document.title = `Vector ${state === "ERROR" ? " [offline]" : ""}${notifCount > 0 ? ` [${notifCount}]` : ""}`;
},

onUserSettingsClose: function() {
Expand Down