Favicon badges
							parent
							
								
									5f6fe74ca8
								
							
						
					
					
						commit
						6ea3f21a8e
					
				| 
						 | 
				
			
			@ -21,6 +21,7 @@
 | 
			
		|||
  },
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "classnames": "^2.1.2",
 | 
			
		||||
    "favico.js": "^0.3.10",
 | 
			
		||||
    "filesize": "^3.1.2",
 | 
			
		||||
    "flux": "^2.0.3",
 | 
			
		||||
    "glob": "^5.0.14",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,7 @@ limitations under the License.
 | 
			
		|||
var React = require('react');
 | 
			
		||||
var Matrix = require("matrix-js-sdk");
 | 
			
		||||
var url = require('url');
 | 
			
		||||
var Favico = require('favico.js');
 | 
			
		||||
 | 
			
		||||
var MatrixClientPeg = require("../../MatrixClientPeg");
 | 
			
		||||
var Notifier = require("../../Notifier");
 | 
			
		||||
| 
						 | 
				
			
			@ -82,6 +83,10 @@ module.exports = React.createClass({
 | 
			
		|||
        };
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    componentWillMount: function() {
 | 
			
		||||
        this.favicon = new Favico({animation: 'none'});
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    componentDidMount: function() {
 | 
			
		||||
        this.dispatcherRef = dis.register(this.onAction);
 | 
			
		||||
        if (this.state.logged_in) {
 | 
			
		||||
| 
						 | 
				
			
			@ -399,6 +404,7 @@ module.exports = React.createClass({
 | 
			
		|||
        var cli = MatrixClientPeg.get();
 | 
			
		||||
        var self = this;
 | 
			
		||||
        cli.on('sync', function(state, prevState) {
 | 
			
		||||
            self.updateFavicon();
 | 
			
		||||
            if (state === "SYNCING" && prevState === "SYNCING") {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -628,6 +634,17 @@ module.exports = React.createClass({
 | 
			
		|||
        this.showScreen("settings");
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    updateFavicon: function() {
 | 
			
		||||
        var notifCount = 0;
 | 
			
		||||
 | 
			
		||||
        var rooms = MatrixClientPeg.get().getRooms();
 | 
			
		||||
        for (var i = 0; i < rooms.length; ++i) {
 | 
			
		||||
            notifCount += rooms[i].unread_notification_count;
 | 
			
		||||
        }
 | 
			
		||||
        this.favicon.badge(notifCount);
 | 
			
		||||
        document.title = (notifCount > 0 ? "["+notifCount+"] " : "")+"Vector";
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    render: function() {
 | 
			
		||||
        var LeftPanel = sdk.getComponent('structures.LeftPanel');
 | 
			
		||||
        var RoomView = sdk.getComponent('structures.RoomView');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue