From d5d11ff181b78b82ae2a96f6f37f2f07eb617ece Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sat, 16 Dec 2017 09:42:26 -0500 Subject: [PATCH] Disable message menu for locally echoed messages. Wait until the server acks a message before we enable the message popover menu. This prevents a whole class of bugs related to re-drawing the message and changing the message id, and it also makes room for a little spinner in the future. Users with decent internet connections will generally get server responses before they can click on the chevron or hit esc/i, anyway. --- static/js/hotkey.js | 2 +- static/js/popovers.js | 11 +++++++++-- static/templates/single_message.handlebars | 4 ++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/static/js/hotkey.js b/static/js/hotkey.js index 440169bd0b..79bc766aa5 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -669,7 +669,7 @@ exports.process_hotkey = function (e, hotkey) { // Shortcuts that operate on a message switch (event_name) { case 'message_actions': - return popovers.open_message_menu(); + return popovers.open_message_menu(msg); case 'star_message': return message_flags.toggle_starred(msg); case 'narrow_by_recipient': diff --git a/static/js/popovers.js b/static/js/popovers.js index 935262fabb..8360d6dac7 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -232,8 +232,15 @@ function focus_first_action_popover_item() { items.eq(0).expectOne().focus(); } -exports.open_message_menu = function () { - var id = current_msg_list.selected_id(); +exports.open_message_menu = function (message) { + if (message.locally_echoed) { + // Don't open the popup for locally echoed messages for now. + // It creates bugs with things like keyboard handlers when + // we get the server response. + return true; + } + + var id = message.id; popovers.toggle_actions_popover($(".selected_message .actions_hover")[0], id); if (current_actions_popover_elem) { focus_first_action_popover_item(); diff --git a/static/templates/single_message.handlebars b/static/templates/single_message.handlebars index 75504dd882..dd0648d2d8 100644 --- a/static/templates/single_message.handlebars +++ b/static/templates/single_message.handlebars @@ -48,9 +48,13 @@ {{/if}} + + {{#unless msg/locally_echoed}}
+ {{/unless}} +