From 3f3a22aa1e7fb43be64f2dad7fbf0546acd900bf Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 12 Feb 2019 14:59:06 +0200 Subject: [PATCH] Disable clicking on the currently active channel channel.id does not change, which causes some wonky behaviour when the channel gets trimmed --- client/js/lounge.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/js/lounge.js b/client/js/lounge.js index 12e22f8e..a0624b34 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -103,11 +103,16 @@ window.vueMounted = () => { // sidebar specifically. Needs to be done better when window management gets // refactored. const inSidebar = self.parents("#sidebar, #footer").length > 0; - let channel; + const channel = inSidebar ? findChannel(Number(self.attr("data-id"))) : null; if (vueApp.activeChannel) { const {channel: lastChannel} = vueApp.activeChannel; + // If user clicks on the currently active channel, do nothing + if (channel && lastChannel === channel.channel) { + return; + } + if (lastChannel.messages.length > 0) { lastChannel.firstUnread = lastChannel.messages[lastChannel.messages.length - 1].id; } @@ -119,8 +124,6 @@ window.vueMounted = () => { } if (inSidebar) { - channel = findChannel(Number(self.attr("data-id"))); - vueApp.activeChannel = channel; if (channel) {