compose_state: Break out stream_name() into separate getter and setter.

This code is equivalent, because the keep_leading_whitespace parameter
of get_or_set was never used for the stream name.

This addresses an open TODO and makes the code more readable.
This commit is contained in:
evykassirer
2022-10-26 15:22:29 -07:00
committed by Tim Abbott
parent 6200f0f734
commit 7f9989003a
8 changed files with 32 additions and 23 deletions

View File

@@ -36,9 +36,18 @@ function get_or_set(fieldname, keep_leading_whitespace) {
};
}
// TODO: Break out setters and getter into their own functions.
export const stream_name = get_or_set("stream_message_recipient_stream");
export function stream_name() {
return $("#stream_message_recipient_stream").val().trim();
}
export function set_stream_name(newval) {
if (newval !== undefined) {
const $elem = $("#stream_message_recipient_stream");
$elem.val(newval);
}
}
// TODO: Break out setter and getter into their own functions.
export const topic = get_or_set("stream_message_recipient_topic");
// We can't trim leading whitespace in `compose_textarea` because