diff --git a/client/components/Windows/Help.vue b/client/components/Windows/Help.vue index b7558c02..19c07aa0 100644 --- a/client/components/Windows/Help.vue +++ b/client/components/Windows/Help.vue @@ -723,7 +723,7 @@ -
+
/search query
diff --git a/client/js/autocompletion.js b/client/js/autocompletion.js index 1acc0057..33ef04a0 100644 --- a/client/js/autocompletion.js +++ b/client/js/autocompletion.js @@ -312,23 +312,18 @@ function completeNicks(word, isFuzzy) { } function getCommands() { - const cmds = constants.commands.slice(); + let cmds = constants.commands.slice(); - if (store.state.settings.searchEnabled === false) { - const search = cmds.indexOf("/search"); - - if (search !== -1) { - cmds.splice(search, 1); - } + if (!store.state.settings.searchEnabled) { + cmds = cmds.filter((c) => c !== "/search"); } return cmds; } function completeCommands(word) { - const words = getCommands(); - - return fuzzyGrep(word, words); + const commands = getCommands(); + return fuzzyGrep(word, commands); } function completeChans(word) { diff --git a/client/js/commands/search.js b/client/js/commands/search.js index 1df3701a..f02deb3b 100644 --- a/client/js/commands/search.js +++ b/client/js/commands/search.js @@ -2,29 +2,22 @@ import store from "../store"; import {router} from "../router"; -const Msg = require("../../../src/models/msg"); function input(args) { - const {channel} = store.state.activeChannel; - if (!store.state.settings.searchEnabled) { - const message = new Msg({ - type: Msg.Type.ERROR, - text: "Search is currently not enabled.", - }); - channel.messages.push(message); - } else { - router.push({ - name: "SearchResults", - params: { - id: channel.id, - }, - query: { - q: args.join(" "), - }, - }); + return false; } + router.push({ + name: "SearchResults", + params: { + id: store.state.activeChannel.channel.id, + }, + query: { + q: args.join(" "), + }, + }); + return true; } diff --git a/client/js/socket-events/commands.js b/client/js/socket-events/commands.js index 0e3e4930..b060fa1c 100644 --- a/client/js/socket-events/commands.js +++ b/client/js/socket-events/commands.js @@ -1,12 +1,8 @@ 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) { - const cmds = [...new Set(commands.concat(clientCommands))]; - constants.commands = cmds.sort(); + constants.commands = commands; } }); diff --git a/src/plugins/inputs/index.js b/src/plugins/inputs/index.js index 6fc5f5f7..5f012254 100644 --- a/src/plugins/inputs/index.js +++ b/src/plugins/inputs/index.js @@ -1,3 +1,5 @@ +const clientSideCommands = ["/collapse", "/expand", "/search"]; + const passThroughCommands = [ "/as", "/bs", @@ -45,6 +47,7 @@ const getCommands = () => Array.from(userInputs.keys()) .concat(Array.from(pluginCommands.keys())) .map((command) => `/${command}`) + .concat(clientSideCommands) .concat(passThroughCommands) .sort();