Don't re-write the message cache while we're processing it.

This commit is contained in:
Ian Gulliver
2016-01-05 19:12:57 -08:00
parent 59fab5e3c6
commit 77227df9aa

View File

@@ -344,9 +344,11 @@ Cosmopolite.prototype.subscribe = function(subjects, opt_messages, opt_lastID) {
var messageStr = localStorage[key]; var messageStr = localStorage[key];
if (messageStr) { if (messageStr) {
var messages = JSON.parse(messageStr); var messages = JSON.parse(messageStr);
subscription.use_cache = false;
messages.forEach(function(msg) { messages.forEach(function(msg) {
msg['message'] = JSON.stringify(msg['message']); msg['message'] = JSON.stringify(msg['message']);
this.onMessage_(msg); this.onMessage_(msg);
subscription.use_cache = true;
}.bind(this)); }.bind(this));
} }
if (subscription.messages.length > 0) { if (subscription.messages.length > 0) {