var /** * @type SlackWrapper **/ SLACK /** * @type {Object.} number of unread per chan **/ ,UNREAD_CHANS = {}; ; /** * @constructor **/ function SlackWrapper() { /** @type {number} */ this.lastServerVersion = 0; /** @type {SlackData} */ this.context = new SlackData(null); /** @type {!Object.} **/ this.history = {}; } SlackWrapper.prototype.update = function(data) { if (data["v"]) this.lastServerVersion = data["v"]; if (data["static"]) { this.context.updateStatic(data["static"]); onContextUpdated(); } if (data["live"]) { for (var i in data["live"]) { var history = this.history[i]; if (!history) this.history[i] = new SlackHistory(i, 500, data["live"][i]); else history.pushAll(data["live"][i]); } for (var roomId in data["live"]) { if (SELECTED_ROOM && data["live"][SELECTED_ROOM.id]) onRoomUpdated(); else onMsgReceived(this.context.getChannel(roomId), data["live"][roomId]); } } }; SLACK = new SlackWrapper();