From ec88ba38a98835776563cde1b648e7eb933dad85 Mon Sep 17 00:00:00 2001 From: pilgrim2308 Date: Thu, 4 Mar 2021 15:39:34 +0530 Subject: [PATCH] UI: Fix redundant condense message appearing in edit message menu. Added the handler functions which were previously missing for when a user tries to edit/view source of a message after expanding it. Fixes #17478 --- static/js/condense.js | 12 ++++++++++++ static/js/message_edit.js | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/static/js/condense.js b/static/js/condense.js index 3807bd678f..b44f16cb45 100644 --- a/static/js/condense.js +++ b/static/js/condense.js @@ -170,12 +170,24 @@ export function hide_message_expander(row) { } } +export function hide_message_condenser(row) { + if (row.find(".could-be-condensed").length !== 0) { + row.find(".message_condenser").hide(); + } +} + export function show_message_expander(row) { if (row.find(".could-be-condensed").length !== 0) { row.find(".message_expander").show(); } } +export function show_message_condenser(row) { + if (row.find(".could-be-condensed").length !== 0) { + row.find(".message_condenser").show(); + } +} + export function condense_and_collapse(elems) { const height_cutoff = message_viewport.height() * 0.65; diff --git a/static/js/message_edit.js b/static/js/message_edit.js index 188d56d8d2..d766a95ea9 100644 --- a/static/js/message_edit.js +++ b/static/js/message_edit.js @@ -293,6 +293,7 @@ function timer_text(seconds_left) { function edit_message(row, raw_content) { row.find(".message_reactions").hide(); condense.hide_message_expander(row); + condense.hide_message_condenser(row); const content_top = row.find(".message_top_line")[0].getBoundingClientRect().top; const message = current_msg_list.get(rows.id(row)); @@ -593,7 +594,11 @@ export function end_message_row_edit(row) { compose.abort_video_callbacks(message.id); } - condense.show_message_expander(row); + if (row.find(".condensed").length !== 0) { + condense.show_message_expander(row); + } else { + condense.show_message_condenser(row); + } row.find(".message_reactions").show(); // We have to blur out text fields, or else hotkeys.js