diff --git a/www/common/common-messaging.js b/www/common/common-messaging.js index 2dbd370ae..7d75a7393 100644 --- a/www/common/common-messaging.js +++ b/www/common/common-messaging.js @@ -79,9 +79,11 @@ define([ friends[pubKey] = data; - Realtime.whenRealtimeSyncs(common.getRealtime(), function () { + Realtime.whenRealtimeSyncs(common, common.getRealtime(), function () { cb(); - common.pinPads([data.channel]); + common.pinPads([data.channel], function (e) { + if (e) { console.error(e); } + }); }); common.changeDisplayName(proxy[common.displayNameKey]); }; diff --git a/www/common/common-messenger.js b/www/common/common-messenger.js index 129c27935..5d2f7351a 100644 --- a/www/common/common-messenger.js +++ b/www/common/common-messenger.js @@ -47,15 +47,6 @@ define([ return proxy.friends ? proxy.friends[pubkey] : undefined; }; - // TODO make this async - var removeFromFriendList = function (proxy, realtime, curvePublic, cb) { - if (!proxy.friends) { return; } - var friends = proxy.friends; - delete friends[curvePublic]; - Realtime.whenRealtimeSyncs(realtime, cb); - }; - - // TODO make this async var getFriendList = Msg.getFriendList = function (proxy) { if (!proxy.friends) { proxy.friends = {}; } return proxy.friends; @@ -93,9 +84,11 @@ define([ friends[pubKey] = data; - Realtime.whenRealtimeSyncs(common.getRealtime(), function () { + Realtime.whenRealtimeSyncs(common, common.getRealtime(), function () { cb(); - common.pinPads([data.channel]); + common.pinPads([data.channel], function (e) { + if (e) { console.error(e); } + }); }); common.changeDisplayName(proxy[common.displayNameKey]); }; @@ -213,14 +206,12 @@ define([ pendingRequests.push(netfluxId); var proxy = common.getProxy(); // this redraws the userlist after a change has occurred - // TODO rename this function to reflect its purpose common.changeDisplayName(proxy[common.displayNameKey]); } network.sendto(netfluxId, msgStr); }; Msg.messenger = function (common) { - 'use strict'; var messenger = { handlers: { message: [], diff --git a/www/common/common-realtime.js b/www/common/common-realtime.js index 216635514..2222dc2bc 100644 --- a/www/common/common-realtime.js +++ b/www/common/common-realtime.js @@ -16,6 +16,10 @@ define([ TODO make this not blow up when disconnected or lagging... */ common.whenRealtimeSyncs = function (Cryptpad, realtime, cb) { + if (typeof(realtime.getAuthDoc) !== 'function') { + return void console.error('improper use of this function'); + } + window.setTimeout(function () { if (realtime.getAuthDoc() === realtime.getUserDoc()) { return void cb(); diff --git a/www/common/rpc.js b/www/common/rpc.js index f088ec0fd..9f04d7663 100644 --- a/www/common/rpc.js +++ b/www/common/rpc.js @@ -24,6 +24,10 @@ types of messages: var hkn = network.historyKeeper; var txid = uid(); + if (typeof(cb) !== 'function') { + return console.error('expected callback'); + } + var pending = ctx.pending[txid] = function (err, response) { cb(err, response); };