Disable /search and hide help item if searching is disabled
This commit is contained in:
parent
3cec329e3b
commit
40a5ee70b6
@ -723,7 +723,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="help-item">
|
||||
<div v-if="$store.state.settings.searchEnabled" class="help-item">
|
||||
<div class="subject">
|
||||
<code>/search query</code>
|
||||
</div>
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user