From a8dcdbcbcb6332ccd85cfd672a7b5d8a387e7979 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 22 Sep 2022 14:20:27 +0530 Subject: [PATCH] fix a bug which prevented old contacts from being removed --- www/common/outer/messenger.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/www/common/outer/messenger.js b/www/common/outer/messenger.js index 85400adc0..bcbd4b48e 100644 --- a/www/common/outer/messenger.js +++ b/www/common/outer/messenger.js @@ -238,6 +238,8 @@ define([ var removeFromFriendList = function (ctx, curvePublic, cb) { var proxy = ctx.store.proxy; var friends = proxy.friends; + // FIXME this probably shouldn't happen, but functions that take callbacks + // should be guaranteed to call back. if (!friends) { return; } delete friends[curvePublic]; Realtime.whenRealtimeSyncs(ctx.store.realtime, function () { @@ -447,7 +449,12 @@ define([ var msg = [Types.unfriend, proxy.curvePublic, +new Date()]; var msgStr = JSON.stringify(msg); var cryptMsg = channel.encrypt(msgStr); - channel.wc.bcast(cryptMsg).then(function () {}, function (err) { + channel.wc.bcast(cryptMsg).then(function () { + onFriendRemoved(ctx, curvePublic, data.channel); + removeFromFriendList(ctx, curvePublic, function () { + cb(); + }); + }, function (err) { if (err) { return void cb({error:err}); } onFriendRemoved(ctx, curvePublic, data.channel); removeFromFriendList(ctx, curvePublic, function () {