From 24a738d521b62dfe401460c5975cda11c3a791a6 Mon Sep 17 00:00:00 2001 From: Nachtalb Date: Thu, 6 May 2021 03:22:09 +0200 Subject: [PATCH] Add new command to open the search window --- client/components/ChatInput.vue | 4 ++++ client/components/Windows/Help.vue | 9 +++++++++ client/js/commands/search.js | 20 ++++++++++++++++++++ src/plugins/inputs/index.js | 2 +- 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 client/js/commands/search.js diff --git a/client/components/ChatInput.vue b/client/components/ChatInput.vue index d12b9405..f0dbb14b 100644 --- a/client/components/ChatInput.vue +++ b/client/components/ChatInput.vue @@ -183,6 +183,10 @@ export default { }, setInputSize() { this.$nextTick(() => { + if (!this.$refs.input) { + return; + } + const style = window.getComputedStyle(this.$refs.input); const lineHeight = parseFloat(style.lineHeight, 10) || 1; diff --git a/client/components/Windows/Help.vue b/client/components/Windows/Help.vue index 7305b1ec..8015bbf8 100644 --- a/client/components/Windows/Help.vue +++ b/client/components/Windows/Help.vue @@ -673,6 +673,15 @@ +
+
+ /search query +
+
+

Search for messages in the current channel / user

+
+
+
/topic [newtopic] diff --git a/client/js/commands/search.js b/client/js/commands/search.js new file mode 100644 index 00000000..31e8c49b --- /dev/null +++ b/client/js/commands/search.js @@ -0,0 +1,20 @@ +"use strict"; + +import store from "../store"; +import {router} from "../router"; + +function input(args) { + router.push({ + name: "SearchResults", + params: { + id: store.state.activeChannel.channel.id, + }, + query: { + q: args.join(" "), + }, + }); + + return true; +} + +export default {input}; diff --git a/src/plugins/inputs/index.js b/src/plugins/inputs/index.js index 911d06cb..5f012254 100644 --- a/src/plugins/inputs/index.js +++ b/src/plugins/inputs/index.js @@ -1,4 +1,4 @@ -const clientSideCommands = ["/collapse", "/expand"]; +const clientSideCommands = ["/collapse", "/expand", "/search"]; const passThroughCommands = [ "/as",