Clear obsolete mentions upon channel part
Currently, the mentions only track the chanID and MsgID. However, when we part a channel the chanID becomes orphaned. Considering that mentions from a parted channel probably aren't that relevant, let's automatically clear them when we part. Should the user really want to look at them again, they can re-join the channel and get the scroll back that way.
This commit is contained in:
parent
acf520bd9a
commit
0d209fce09
@ -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) {
|
Client.prototype.quit = function (signOut) {
|
||||||
const sockets = this.manager.sockets.sockets;
|
const sockets = this.manager.sockets.sockets;
|
||||||
const room = sockets.adapter.rooms.get(this.id);
|
const room = sockets.adapter.rooms.get(this.id);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const _ = require("lodash");
|
|
||||||
const Msg = require("../../models/msg");
|
const Msg = require("../../models/msg");
|
||||||
const Chan = require("../../models/chan");
|
const Chan = require("../../models/chan");
|
||||||
const Helper = require("../../helper");
|
const Helper = require("../../helper");
|
||||||
@ -41,12 +40,7 @@ exports.input = function (network, chan, cmd, args) {
|
|||||||
!network.irc.connection ||
|
!network.irc.connection ||
|
||||||
!network.irc.connection.connected
|
!network.irc.connection.connected
|
||||||
) {
|
) {
|
||||||
network.channels = _.without(network.channels, target);
|
this.part(network, target);
|
||||||
target.destroy();
|
|
||||||
this.emit("part", {
|
|
||||||
chan: target.id,
|
|
||||||
});
|
|
||||||
this.save();
|
|
||||||
} else {
|
} else {
|
||||||
const partMessage = args.join(" ") || network.leaveMessage || Helper.config.leaveMessage;
|
const partMessage = args.join(" ") || network.leaveMessage || Helper.config.leaveMessage;
|
||||||
network.irc.part(target.name, partMessage);
|
network.irc.part(target.name, partMessage);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const _ = require("lodash");
|
|
||||||
const Msg = require("../../models/msg");
|
const Msg = require("../../models/msg");
|
||||||
|
|
||||||
module.exports = function (irc, network) {
|
module.exports = function (irc, network) {
|
||||||
@ -25,12 +24,7 @@ module.exports = function (irc, network) {
|
|||||||
chan.pushMessage(client, msg);
|
chan.pushMessage(client, msg);
|
||||||
|
|
||||||
if (data.nick === irc.user.nick) {
|
if (data.nick === irc.user.nick) {
|
||||||
network.channels = _.without(network.channels, chan);
|
client.part(network, chan);
|
||||||
chan.destroy();
|
|
||||||
client.save();
|
|
||||||
client.emit("part", {
|
|
||||||
chan: chan.id,
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
chan.removeUser(user);
|
chan.removeUser(user);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user