Merge branch 'bookworm/mentions'

This commit is contained in:
Reto Brunner 2022-01-03 09:28:29 +01:00
commit 4db2d28216
5 changed files with 28 additions and 19 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();

View File

@ -649,6 +649,17 @@ Client.prototype.names = function (data) {
});
};
Client.prototype.part = function (network, chan) {
const client = this;
network.channels = _.without(network.channels, chan);
client.mentions = client.mentions.filter((msg) => !(msg.chanId === chan.id));
chan.destroy();
client.save();
client.emit("part", {
chan: chan.id,
});
};
Client.prototype.quit = function (signOut) {
const sockets = this.manager.sockets.sockets;
const room = sockets.adapter.rooms.get(this.id);

View File

@ -1,6 +1,5 @@
"use strict";
const _ = require("lodash");
const Msg = require("../../models/msg");
const Chan = require("../../models/chan");
const Helper = require("../../helper");
@ -41,12 +40,7 @@ exports.input = function (network, chan, cmd, args) {
!network.irc.connection ||
!network.irc.connection.connected
) {
network.channels = _.without(network.channels, target);
target.destroy();
this.emit("part", {
chan: target.id,
});
this.save();
this.part(network, target);
} else {
const partMessage = args.join(" ") || network.leaveMessage || Helper.config.leaveMessage;
network.irc.part(target.name, partMessage);

View File

@ -1,6 +1,5 @@
"use strict";
const _ = require("lodash");
const Msg = require("../../models/msg");
module.exports = function (irc, network) {
@ -25,12 +24,7 @@ module.exports = function (irc, network) {
chan.pushMessage(client, msg);
if (data.nick === irc.user.nick) {
network.channels = _.without(network.channels, chan);
chan.destroy();
client.save();
client.emit("part", {
chan: chan.id,
});
client.part(network, chan);
} else {
chan.removeUser(user);
}