mirror of
https://github.com/thelounge/thelounge
synced 2024-11-14 00:07:17 +00:00
Optimise commands processing
This commit is contained in:
parent
bbda392c3d
commit
0d839c501e
2 changed files with 13 additions and 7 deletions
|
@ -6,7 +6,6 @@ import Mousetrap from "mousetrap";
|
|||
import {Textcomplete, Textarea} from "textcomplete";
|
||||
import fuzzy from "fuzzy";
|
||||
|
||||
import commands from "./commands/index";
|
||||
import emojiMap from "./helpers/simplemap.json";
|
||||
import store from "./store";
|
||||
|
||||
|
@ -313,14 +312,17 @@ function completeNicks(word, isFuzzy) {
|
|||
}
|
||||
|
||||
function getCommands() {
|
||||
const clientCommands = Object.keys(commands).map((cmd) => `/${cmd}`);
|
||||
const cmds = [...new Set(Array.from(constants.commands).concat(clientCommands))];
|
||||
const cmds = constants.commands;
|
||||
|
||||
if (!store.state.settings.searchEnabled) {
|
||||
cmds.pop("/search");
|
||||
if (store.state.settings.searchEnabled === false) {
|
||||
const search = cmds.indexOf("/search");
|
||||
|
||||
if (search !== -1) {
|
||||
cmds.splice(search, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return cmds.sort();
|
||||
return cmds;
|
||||
}
|
||||
|
||||
function completeCommands(word) {
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
const constants = require("../constants");
|
||||
import localCommands from "../commands/index";
|
||||
import socket from "../socket";
|
||||
|
||||
const clientCommands = Object.keys(localCommands).map((cmd) => `/${cmd}`);
|
||||
|
||||
socket.on("commands", function (commands) {
|
||||
if (commands) {
|
||||
constants.commands = commands;
|
||||
const cmds = [...new Set(commands.concat(clientCommands))];
|
||||
constants.commands = cmds.sort();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue