From 6370c0eeae513b91489ae27681db5ac770e3070a Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 27 May 2019 16:03:10 +0200 Subject: [PATCH] Update the profile page when receiving a answer for a friend request --- www/common/outer/mailbox-handlers.js | 5 +++++ www/common/outer/profile.js | 3 +++ 2 files changed, 8 insertions(+) diff --git a/www/common/outer/mailbox-handlers.js b/www/common/outer/mailbox-handlers.js index 061c4640a..6f2c6c04d 100644 --- a/www/common/outer/mailbox-handlers.js +++ b/www/common/outer/mailbox-handlers.js @@ -51,6 +51,8 @@ define([ delete ctx.store.proxy.friends_pending[data.msg.author]; ctx.updateMetadata(); if (friendRequestDeclined[data.msg.author]) { return; } + // If you have a profile page open, update it + if (ctx.store.modules['profile']) { ctx.store.modules['profile'].update(); } box.sendMessage({ type: 'FRIEND_REQUEST_DECLINED', content: { @@ -95,6 +97,9 @@ define([ ctx.store.messenger.onFriendAdded(data.msg.content); } ctx.updateMetadata(); + if (friendRequestAccepted[data.msg.author]) { return; } + // If you have a profile page open, update it + if (ctx.store.modules['profile']) { ctx.store.modules['profile'].update(); } // Display the "accepted" state in the UI box.sendMessage({ type: 'FRIEND_REQUEST_ACCEPTED', diff --git a/www/common/outer/profile.js b/www/common/outer/profile.js index f914cc77c..5ecdcc235 100644 --- a/www/common/outer/profile.js +++ b/www/common/outer/profile.js @@ -134,6 +134,9 @@ define([ profile.removeClient = function (clientId) { removeClient(ctx, clientId); }; + profile.update = function () { + ctx.emit('UPDATE', ctx.listmap.proxy, ctx.clients); + }; profile.execCommand = function (clientId, obj, cb) { console.log(obj); var cmd = obj.cmd;