| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- var
- /**
- * @type SlackWrapper
- **/
- SLACK
- /**
- * @type {Object.<string, number>} number of unread per chan
- **/
- ,UNREAD_CHANS = {};
- ;
- /**
- * @constructor
- **/
- function SlackWrapper() {
- /** @type {number} */
- this.lastServerVersion = 0;
- /** @type {SlackData} */
- this.context = new SlackData(null);
- /** @type {!Object.<string, SlackHistory>} **/
- 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, 250, data["live"][i]);
- else
- history.pushAll(data["live"][i]);
- }
- for (var roomId in data["live"]) {
- onMsgReceived(this.context.getChannel(roomId), data["live"][roomId]);
- if (SELECTED_ROOM && data["live"][SELECTED_ROOM.id])
- onRoomUpdated();
- }
- }
- };
- SLACK = new SlackWrapper();
|