Skip to content

Commit

Permalink
refactor: Refactor the compose placeholder text function.
Browse files Browse the repository at this point in the history
This is a prep commit. Refactoring this makes it easier to reuse
these functions in other places without having to create the `opts`
object again.
  • Loading branch information
vinitS101 authored and timabbott committed Sep 1, 2020
1 parent a01d333 commit afa8715
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 1 addition & 7 deletions static/js/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -1222,13 +1222,7 @@ exports.initialize = function () {
});

$("#compose-textarea").on("focus", () => {
const opts = {
message_type: compose_state.get_message_type(),
stream: $("#stream_message_recipient_stream").val(),
topic: $("#stream_message_recipient_topic").val(),
private_message_recipient: compose_pm_pill.get_emails(),
};
compose_actions.update_placeholder_text(opts);
compose_actions.update_placeholder_text();
});

if (page_params.narrow !== undefined) {
Expand Down
14 changes: 10 additions & 4 deletions static/js/compose_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ exports.complete_starting_tasks = function (msg_type, opts) {
compose_fade.start_compose(msg_type);
ui_util.decorate_stream_bar(opts.stream, $("#stream-message .message_header_stream"), true);
$(document).trigger($.Event("compose_started.zulip", opts));
exports.update_placeholder_text(opts);
exports.update_placeholder_text();
};

exports.maybe_scroll_up_selected_message = function () {
Expand Down Expand Up @@ -171,9 +171,15 @@ function same_recipient_as_before(msg_type, opts) {
);
}

exports.update_placeholder_text = function (opts) {
const placeholder_text = compose_ui.compute_placeholder_text(opts);
$("#compose-textarea").attr("placeholder", placeholder_text);
exports.update_placeholder_text = function () {
const opts = {
message_type: compose_state.get_message_type(),
stream: $("#stream_message_recipient_stream").val(),
topic: $("#stream_message_recipient_topic").val(),
private_message_recipient: compose_pm_pill.get_emails(),
};

$("#compose-textarea").attr("placeholder", compose_ui.compute_placeholder_text(opts));
};

exports.start = function (msg_type, opts) {
Expand Down

0 comments on commit afa8715

Please sign in to comment.