Shortcut calling onMessage for everything in cache.
This commit is contained in:
@@ -343,12 +343,13 @@ Cosmopolite.prototype.subscribe = function(subjects, opt_messages, opt_lastID) {
|
|||||||
var key = this.messageCacheKeyPrefix_ + subjectString;
|
var key = this.messageCacheKeyPrefix_ + subjectString;
|
||||||
var messageStr = localStorage[key];
|
var messageStr = localStorage[key];
|
||||||
if (messageStr) {
|
if (messageStr) {
|
||||||
var messages = JSON.parse(messageStr);
|
subscription.messages = JSON.parse(messageStr);
|
||||||
subscription.use_cache = false;
|
// Simplified version of onMessage_, to avoid a bunch of the
|
||||||
messages.forEach(function(msg) {
|
// overhead.
|
||||||
msg['message'] = JSON.stringify(msg['message']);
|
subscription.messages.forEach(function(msg) {
|
||||||
this.onMessage_(msg);
|
this.dispatchEvent(new CustomEvent('message', {
|
||||||
subscription.use_cache = true;
|
'detail': msg,
|
||||||
|
}));
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
if (subscription.messages.length > 0) {
|
if (subscription.messages.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user