From 8017fc9a15a6665c63e896b58366e4dc54b93b84 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Thu, 10 Oct 2013 09:54:18 -0400 Subject: [PATCH] Move compose.start() calls out of click handlers. For the two cases where narrowing should open the compose box, we now put that logic inside of narrow.js. (imported from commit 570e22e90c2f6d422ba71cce400c075f0b8adf51) --- static/js/compose.js | 16 ---------------- static/js/narrow.js | 11 ++++++++++- static/js/ui.js | 7 +------ 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/static/js/compose.js b/static/js/compose.js index 2b1ea7767d..99adb3fb85 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -117,22 +117,6 @@ exports.decorate_stream_bar = function (stream_name) { .addClass(stream_color.get_color_class(color)); }; -exports.update_recipient_on_narrow = function () { - if (!compose.composing()) { - return; - } - if (compose.message_content() !== "") { - return; - } - var compose_opts = {}; - narrow.set_compose_defaults(compose_opts); - if (compose_opts.stream) { - compose.start("stream"); - } else { - compose.start("private"); - } -}; - function update_fade () { if (!is_composing_message) { return; diff --git a/static/js/narrow.js b/static/js/narrow.js index c5b979dc31..861405fbdc 100644 --- a/static/js/narrow.js +++ b/static/js/narrow.js @@ -242,7 +242,16 @@ exports.activate = function (operators, opts) { // Put the narrow operators in the search bar. $('#search_query').val(Filter.unparse(operators)); search.update_button_visibility(); - compose.update_recipient_on_narrow(); + + if (opts.trigger === 'sidebar' && exports.narrowed_by_reply()) { + if (exports.narrowed_to_topic()) { + compose.start('stream'); + } + else { + compose.start('private'); + } + } + compose_fade.update_message_list(); $(document).trigger($.Event('narrow_activated.zulip', {msg_list: narrowed_msg_list, diff --git a/static/js/ui.js b/static/js/ui.js index 248c83f991..4405a39131 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -1309,9 +1309,7 @@ $(function () { $('#user_presences').on('click', '.selectable_sidebar_block', function (e) { var email = $(e.target).parents('li').attr('data-email'); - narrow.by('pm-with', email, {trigger: 'presence list'}); - compose.start('private', {private_message_recipient: email, - trigger: 'presence list'}); + narrow.by('pm-with', email, {trigger: 'sidebar'}); // The preventDefault is necessary so that clicking the // link doesn't jump us to the top of the page. e.preventDefault(); @@ -1361,9 +1359,6 @@ $(function () { ['topic', subject]], {select_first_unread: true, trigger: 'sidebar'}); - compose.start('stream', {stream: stream, subject: subject, - trigger: 'sidebar subject click'}); - e.preventDefault(); });