|
|
@@ -148,17 +148,11 @@ Slack.prototype.onMessage = function(msg) {
|
|
|
this.data.onMessage(msg);
|
|
|
if (msg["channel"] && msg["type"] === "message") {
|
|
|
var histo = this.history[msg["channel"]];
|
|
|
- if (!histo) {
|
|
|
- if (this.data.getChannel(msg["channel"])) {
|
|
|
- this.fetchHistory(msg["channel"], ((histo) => {
|
|
|
- histo.push(msg);
|
|
|
- this.data.liveV = Math.max(this.data.liveV, parseFloat(msg["ts"]));
|
|
|
- }).bind(this));
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
+ if (histo) {
|
|
|
histo.push(msg);
|
|
|
this.data.liveV = Math.max(this.data.liveV, parseFloat(msg["ts"]));
|
|
|
+ } else if (this.data.getChannel(msg["channel"])) {
|
|
|
+ this.fetchHistory(msg["channel"]);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -203,7 +197,7 @@ Slack.getOauthToken = function(code, cb) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-Slack.prototype.fetchHistory = function(targetId, callback) {
|
|
|
+Slack.prototype.fetchHistory = function(targetId) {
|
|
|
var _this = this
|
|
|
,baseUrl = "";
|
|
|
|
|
|
@@ -227,8 +221,7 @@ Slack.prototype.fetchHistory = function(targetId, callback) {
|
|
|
history = _this.history[targetId] = new SlackHistory(targetId, HISTORY_LENGTH, resp.messages);
|
|
|
history.isNew = true;
|
|
|
}
|
|
|
- if (callback)
|
|
|
- callback(history);
|
|
|
+ //TODO update this.data.liveV
|
|
|
}
|
|
|
});
|
|
|
};
|