compose: Show topic resolve warning only when compose is nonempty.

The resolve topic warning can feel like clutter in the event that the
compose box is empty (which often occurs when the user has no intent
to send a message), so we configure the validation logic to only
display the notice when the compose box is non-empty.

We take some care to minimize work the function is doing, beacuse it
is called on every keystroke in the compose box.

Fixes: #21155.
This commit is contained in:
Tim Abbott
2022-03-15 17:31:01 -07:00
committed by Tim Abbott
parent ab7415105d
commit 562f37b9af
5 changed files with 52 additions and 18 deletions

View File

@@ -291,7 +291,7 @@ export function start(msg_type, opts) {
show_box(msg_type, opts);
// Show a warning if topic is resolved
compose_validate.warn_if_topic_resolved();
compose_validate.warn_if_topic_resolved(true);
// Reset the `max-height` property of `compose-textarea` so that the
// compose-box do not cover the last messages of the current stream
@@ -464,7 +464,7 @@ export function on_topic_narrow() {
// See #3300 for context--a couple users specifically asked for
// this convenience.
compose_state.topic(narrow_state.topic());
compose_validate.warn_if_topic_resolved();
compose_validate.warn_if_topic_resolved(true);
compose_fade.set_focused_recipient("stream");
compose_fade.update_message_list();
$("#compose-textarea").trigger("focus").trigger("select");