Optimise commands processing
This commit is contained in:
parent
bbda392c3d
commit
0d839c501e
@ -6,7 +6,6 @@ import Mousetrap from "mousetrap";
|
|||||||
import {Textcomplete, Textarea} from "textcomplete";
|
import {Textcomplete, Textarea} from "textcomplete";
|
||||||
import fuzzy from "fuzzy";
|
import fuzzy from "fuzzy";
|
||||||
|
|
||||||
import commands from "./commands/index";
|
|
||||||
import emojiMap from "./helpers/simplemap.json";
|
import emojiMap from "./helpers/simplemap.json";
|
||||||
import store from "./store";
|
import store from "./store";
|
||||||
|
|
||||||
@ -313,14 +312,17 @@ function completeNicks(word, isFuzzy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCommands() {
|
function getCommands() {
|
||||||
const clientCommands = Object.keys(commands).map((cmd) => `/${cmd}`);
|
const cmds = constants.commands;
|
||||||
const cmds = [...new Set(Array.from(constants.commands).concat(clientCommands))];
|
|
||||||
|
|
||||||
if (!store.state.settings.searchEnabled) {
|
if (store.state.settings.searchEnabled === false) {
|
||||||
cmds.pop("/search");
|
const search = cmds.indexOf("/search");
|
||||||
|
|
||||||
|
if (search !== -1) {
|
||||||
|
cmds.splice(search, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmds.sort();
|
return cmds;
|
||||||
}
|
}
|
||||||
|
|
||||||
function completeCommands(word) {
|
function completeCommands(word) {
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
const constants = require("../constants");
|
const constants = require("../constants");
|
||||||
|
import localCommands from "../commands/index";
|
||||||
import socket from "../socket";
|
import socket from "../socket";
|
||||||
|
|
||||||
|
const clientCommands = Object.keys(localCommands).map((cmd) => `/${cmd}`);
|
||||||
|
|
||||||
socket.on("commands", function (commands) {
|
socket.on("commands", function (commands) {
|
||||||
if (commands) {
|
if (commands) {
|
||||||
constants.commands = commands;
|
const cmds = [...new Set(commands.concat(clientCommands))];
|
||||||
|
constants.commands = cmds.sort();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user