From 0b59cf92b9f1eccfa34456c42c702bec091474fa Mon Sep 17 00:00:00 2001 From: Noelle Leigh Date: Mon, 20 Dec 2021 15:09:10 -0500 Subject: [PATCH] Display persistant command input on server buffer This commit changes the composer to not be read-only on the server buffer, which tells the user that they can send commands from that view. On the server buffer, the placeholder is changed to "Type a command (see /help)", which indicates to the user that this buffer only accepts commands, and gives them a hint for how to learn what commands are available. Implements: https://todo.sr.ht/~emersion/gamja/38 --- components/app.js | 9 ++++++--- components/composer.js | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/components/app.js b/components/app.js index 2b98575..55d4087 100644 --- a/components/app.js +++ b/components/app.js @@ -1759,13 +1759,15 @@ export default class App extends Component { } let composerReadOnly = false; - if (activeBuffer && activeBuffer.type === BufferType.SERVER) { - composerReadOnly = true; - } if (activeServer && activeServer.status !== ServerStatus.REGISTERED) { composerReadOnly = true; } + let commandOnly = false + if (activeBuffer && activeBuffer.type === BufferType.SERVER) { + commandOnly = true + } + return html`
${dialog} ${error} diff --git a/components/composer.js b/components/composer.js index b9f5ee8..f029381 100644 --- a/components/composer.js +++ b/components/composer.js @@ -143,7 +143,7 @@ export default class Composer extends Component { return; } - if (this.props.readOnly && event.key !== "/") { + if (this.props.readOnly || (this.props.commandOnly && event.key !== "/")) { return; } @@ -201,6 +201,11 @@ export default class Composer extends Component { className = "read-only"; } + let placeholder = "Type a message"; + if (this.props.commandOnly) { + placeholder = "Type a command (see /help)"; + } + return html`