mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-08 08:42:17 +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>
34 lines
597 B
JavaScript
34 lines
597 B
JavaScript
"use strict";
|
|
|
|
class Prefix {
|
|
constructor(prefix) {
|
|
this.prefix = prefix || []; // [{symbol: "@", mode: "o"}, ... ]
|
|
this.modeToSymbol = {};
|
|
this.symbols = [];
|
|
this._update_internals();
|
|
}
|
|
|
|
_update_internals() {
|
|
// clean out the old cruft
|
|
this.modeToSymbol = {};
|
|
this.symbols = [];
|
|
|
|
const that = this;
|
|
this.prefix.forEach(function (p) {
|
|
that.modeToSymbol[p.mode] = p.symbol;
|
|
that.symbols.push(p.symbol);
|
|
});
|
|
}
|
|
|
|
update(prefix) {
|
|
this.prefix = prefix || [];
|
|
this._update_internals();
|
|
}
|
|
|
|
forEach(f) {
|
|
return this.prefix.forEach(f);
|
|
}
|
|
}
|
|
|
|
module.exports = Prefix;
|