From 7687c90edcd8a663e3a2a4e4c93434cd7f515468 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 15 Oct 2019 20:33:03 +0300 Subject: [PATCH] Synchronize user list correctly on reconnection --- client/js/socket-events/init.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/js/socket-events/init.js b/client/js/socket-events/init.js index f3ccbfc0..7090ea7d 100644 --- a/client/js/socket-events/init.js +++ b/client/js/socket-events/init.js @@ -163,7 +163,16 @@ function mergeChannelData(oldChannels, newChannels) { // Server sends an empty users array, client requests it whenever needed if (key === "users") { if (channel.type === "channel") { - channel.usersOutdated = true; + if (vueApp.activeChannel && vueApp.activeChannel.channel === currentChannel) { + // For currently open channel, request the user list straight away + socket.emit("names", { + target: channel.id, + }); + } else { + // For all other channels, mark the user list as outdated + // so an update will be requested whenever user switches to these channels + currentChannel.usersOutdated = true; + } } continue;