compose validate: Rename overflow verifier.

This makes it clearer what the return value means.
This commit is contained in:
evykassirer 2023-03-27 23:35:22 -07:00 committed by Tim Abbott
parent b406cc84ff
commit 83b484db32
3 changed files with 4 additions and 4 deletions

View File

@ -598,7 +598,7 @@ export function check_overflow_text() {
return text.length;
}
export function warn_for_text_overflow_when_tries_to_send() {
export function validate_message_length() {
if (compose_state.message_content().length > page_params.max_message_length) {
$("#compose-textarea").addClass("flash");
setTimeout(() => $("#compose-textarea").removeClass("flash"), 1500);
@ -624,7 +624,7 @@ export function validate() {
);
return false;
}
if (!warn_for_text_overflow_when_tries_to_send()) {
if (!validate_message_length()) {
return false;
}

View File

@ -231,7 +231,7 @@ function handle_keydown(e) {
if (should_enter_send(e)) {
e.preventDefault();
if (
compose_validate.warn_for_text_overflow_when_tries_to_send() &&
compose_validate.validate_message_length() &&
!$("#compose-send-button").prop("disabled")
) {
compose.finish();

View File

@ -13,7 +13,7 @@ const compose = mock_esm("../src/compose", {
finish: noop,
});
const compose_validate = mock_esm("../src/compose_validate", {
warn_for_text_overflow_when_tries_to_send: () => true,
validate_message_length: () => true,
});
const input_pill = mock_esm("../src/input_pill");
const message_user_ids = mock_esm("../src/message_user_ids", {