mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-10 09:42:18 +02:00
8fcd079204
* properly track user modes for context menu The RPL_ISUPPORT response contains a PREFIX element, which not only tracks the prefix chars ("@", "+" etc) but also their corresponding mode chars (+O, +v) This commit changes the context menu to not rely on a hardcoded list but rather user the one given in the prefix response by the server. Co-authored-by: Max Leiter <maxwell.leiter@gmail.com>
36 lines
636 B
JavaScript
36 lines
636 B
JavaScript
"use strict";
|
|
|
|
const _ = require("lodash");
|
|
|
|
module.exports = User;
|
|
|
|
function User(attr, prefix) {
|
|
_.defaults(this, attr, {
|
|
modes: [],
|
|
away: "",
|
|
nick: "",
|
|
lastMessage: 0,
|
|
});
|
|
|
|
Object.defineProperty(this, "mode", {
|
|
get() {
|
|
return this.modes[0] || "";
|
|
},
|
|
});
|
|
|
|
this.setModes(this.modes, prefix);
|
|
}
|
|
|
|
User.prototype.setModes = function (modes, prefix) {
|
|
// irc-framework sets character mode, but The Lounge works with symbols
|
|
this.modes = modes.map((mode) => prefix.modeToSymbol[mode]);
|
|
};
|
|
|
|
User.prototype.toJSON = function () {
|
|
return {
|
|
nick: this.nick,
|
|
modes: this.modes,
|
|
lastMessage: this.lastMessage,
|
|
};
|
|
};
|