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();