From 1acbeaee12e023e5e0b63f5fee277b57f273c868 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sun, 27 Dec 2015 17:12:12 -0800 Subject: [PATCH] Delay hogfather promise resolution until subscription syncs up. --- static/hogfather.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/static/hogfather.js b/static/hogfather.js index 0b15a9e..6ef5bc4 100644 --- a/static/hogfather.js +++ b/static/hogfather.js @@ -30,9 +30,7 @@ var hogfather = {}; hogfather.PublicChat = function(cosmo, id) { this.cosmo_ = cosmo; this.id_ = id; - this.group_ = '/hogfather/public/' + id; - - console.log(this.loggingPrefix_(), 'construct'); + this.subject_ = '/hogfather/public/' + id; }; @@ -68,9 +66,13 @@ hogfather.PublicChat.Join = function(cosmo, id) { */ hogfather.PublicChat.prototype.Start = function() { return new Promise(function(resolve, reject) { - // XXX - resolve(); - }); + this.cosmo_.subscribe(this.subject_, -1).then(function() { + console.log(this.loggingPrefix_(), 'ready'); + resolve(); + }.bind(this)).catch(function(err) { + reject(err); + }); + }.bind(this)); };