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.
This commit is contained in:
Reto Brunner 2021-12-29 16:31:44 +01:00
parent 0d209fce09
commit e999171f29
2 changed files with 15 additions and 5 deletions

View File

@ -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);
});

View File

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