From 78ff55e34e9bb55db832d6861597cb0edb46b3b6 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 6 Jun 2018 18:21:52 +0200 Subject: [PATCH] Fix race condition --- www/common/cryptpad-common.js | 1 + www/common/outer/async-store.js | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index b04660c51..41305240d 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -858,6 +858,7 @@ define([ }); postMessage = function (cmd, data, cb) { + cb = cb || function () {} chan.query(cmd, data, function (err, data) { if (err) { return void cb ({error: err}); } cb(data); diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 172ff406d..1608c8eda 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -981,6 +981,11 @@ define([ } if (!isNew && channel.wc) { + postMessage(clientId, "PAD_CONNECT", { + myID: channel.wc.myID, + id: channel.wc.id, + members: channel.wc.members + }); channel.wc.members.forEach(function (m) { postMessage(clientId, "PAD_JOIN", m); }); @@ -992,11 +997,6 @@ define([ }); }); postMessage(clientId, "PAD_READY"); - cb({ - myID: channel.wc.myID, - id: channel.wc.id, - members: channel.wc.members - }); return; }