From b6d5e6d6ae9ed503684e5a7732425e206a43af10 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Tue, 27 May 2014 10:35:00 -0700 Subject: [PATCH] Fix completely broken repin-on-connect behavior --- static/cosmopolite.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/static/cosmopolite.js b/static/cosmopolite.js index de41397..269892f 100644 --- a/static/cosmopolite.js +++ b/static/cosmopolite.js @@ -621,9 +621,9 @@ Cosmopolite.prototype.flushRPCQueue_ = function() { }; /** - * Resubscribe to subjects (i.e. after reconnection) + * Handle tasks needed after reconnecting the channel */ -Cosmopolite.prototype.resubscribe_ = function() { +Cosmopolite.prototype.onReconnect_ = function() { var rpcs = []; for (var subject in this.subscriptions_) { var subscription = this.subscriptions_[subject]; @@ -642,12 +642,13 @@ Cosmopolite.prototype.resubscribe_ = function() { 'last_id': last_id, } }); - subscription.pins.forEach(function(pin) { - rpcs.push({ - 'command': 'pin', - 'arguments': pin, - }); - }, this); + } + for (var id in this.pins_) { + var pin = this.pins_[id]; + rpcs.push({ + 'command': 'pin', + 'arguments': pin, + }); } this.sendRPCs_(rpcs); }; @@ -719,7 +720,7 @@ Cosmopolite.prototype.onSocketOpen_ = function() { } this.flushRPCQueue_(); - this.resubscribe_(); + this.onReconnect_(); }; /**