From e999171f291ddbe93c46a78e977299c587931a5e Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Wed, 29 Dec 2021 16:31:44 +0100 Subject: [PATCH] Mentions window: filter list when we part a chan Should some other client part a chan, then we need to clean up the list from the mentions window in case it's open in ours. --- client/js/socket-events/part.js | 14 +++++++++----- client/js/store.js | 6 ++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/client/js/socket-events/part.js b/client/js/socket-events/part.js index 58be3a57..7706f41c 100644 --- a/client/js/socket-events/part.js +++ b/client/js/socket-events/part.js @@ -12,10 +12,14 @@ socket.on("part", function (data) { const channel = store.getters.findChannel(data.chan); - if (channel) { - channel.network.channels.splice( - channel.network.channels.findIndex((c) => c.id === data.chan), - 1 - ); + if (!channel) { + return; } + + channel.network.channels.splice( + channel.network.channels.findIndex((c) => c.id === data.chan), + 1 + ); + + store.dispatch("partChannel", channel); }); diff --git a/client/js/store.js b/client/js/store.js index 83ce7f86..53659934 100644 --- a/client/js/store.js +++ b/client/js/store.js @@ -130,6 +130,12 @@ const store = new Vuex.Store({ state.messageSearchResults = value; }, }, + actions: { + partChannel({commit, state}, netChan) { + const mentions = state.mentions.filter((msg) => !(msg.chanId === netChan.channel.id)); + commit("mentions", mentions); + }, + }, getters: { findChannelOnCurrentNetwork: (state) => (name) => { name = name.toLowerCase();