Merge pull request #221 from aviraldg/feature-sync-status
Display sync status in favicon and title.
This commit is contained in:
commit
6016ba70d9
1 changed files with 14 additions and 4 deletions
|
@ -630,7 +630,7 @@ module.exports = React.createClass({
|
||||||
var cli = MatrixClientPeg.get();
|
var cli = MatrixClientPeg.get();
|
||||||
var self = this;
|
var self = this;
|
||||||
cli.on('sync', function(state, prevState) {
|
cli.on('sync', function(state, prevState) {
|
||||||
self.updateFavicon();
|
self.updateFavicon(state, prevState);
|
||||||
if (state === "SYNCING" && prevState === "SYNCING") {
|
if (state === "SYNCING" && prevState === "SYNCING") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -924,7 +924,7 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
updateFavicon: function() {
|
updateFavicon: function(state, prevState) {
|
||||||
var notifCount = 0;
|
var notifCount = 0;
|
||||||
|
|
||||||
var rooms = MatrixClientPeg.get().getRooms();
|
var rooms = MatrixClientPeg.get().getRooms();
|
||||||
|
@ -939,11 +939,21 @@ module.exports = React.createClass({
|
||||||
// This needs to be in in a try block as it will throw
|
// This needs to be in in a try block as it will throw
|
||||||
// if there are more than 100 badge count changes in
|
// if there are more than 100 badge count changes in
|
||||||
// its internal queue
|
// 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) {
|
} catch (e) {
|
||||||
console.warn("Failed to set badge count: "+e.message);
|
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() {
|
onUserSettingsClose: function() {
|
||||||
|
|
Loading…
Reference in a new issue