Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message view: Allow muted user message to be rehidden.
m-e-l-u-h-a-ncaa5ec74c2f3
diff --git a/frontend_tests/node_tests/message_list_view.js b/frontend_tests/node_tests/message_list_view.jsindex ccbdf3c4169..77148fe0d64 100644--- a/frontend_tests/node_tests/message_list_view.js+++ b/frontend_tests/node_tests/message_list_view.js@@ -203,7 +203,7 @@ test("muted_message_vars", () => {assert.equal(result[1].contains_mention, false);// Now, reveal the hidden messages.- const is_revealed = true;+ let is_revealed = true;result = calculate_variables(list, messages, is_revealed);// Check that `is_hidden` is false and `include_sender` is true on all messages.@@ -217,6 +217,22 @@ test("muted_message_vars", () => {// Additionally test that, `contains_mention` is true on that message which has a mention.assert.equal(result[1].contains_mention, true);++ // Now test rehiding muted user's messsage+ is_revealed = false;+ result = calculate_variables(list, messages, is_revealed);++ // Check that `is_hidden` is false and `include_sender` is false on all messages.+ assert.equal(result[0].is_hidden, true);+ assert.equal(result[1].is_hidden, true);+ assert.equal(result[2].is_hidden, true);++ assert.equal(result[0].include_sender, false);+ assert.equal(result[1].include_sender, false);+ assert.equal(result[2].include_sender, false);++ // Additionally test that, `contains_mention` is false on that message which has a mention.+ assert.equal(result[1].contains_mention, false);})();});diff --git a/frontend_tests/node_tests/popovers.js b/frontend_tests/node_tests/popovers.jsindex 55b24901aba..bec0fe2a583 100644--- a/frontend_tests/node_tests/popovers.js+++ b/frontend_tests/node_tests/popovers.js@@ -21,7 +21,11 @@ mock_esm("../../static/js/giphy", {hide_giphy_popover: noop,});const message_lists = mock_esm("../../static/js/message_lists", {- current: {},+ current: {+ view: {+ message_containers: {},+ },+ },});mock_esm("../../static/js/message_viewport", {height: () => 500,@@ -230,6 +234,13 @@ test_ui("actions_popover", (override) => {return message;};+ message_lists.current.view.message_containers.get = (msg_id) => {+ assert.equal(msg_id, message.id);+ return {+ is_hidden: false,+ };+ };+override(message_edit, "get_editability", () => 4);stream_data.id_to_slug = (stream_id) => {diff --git a/static/js/message_list_view.js b/static/js/message_list_view.jsindex 366d3f0a096..5a375728b0a 100644--- a/static/js/message_list_view.js+++ b/static/js/message_list_view.js@@ -1186,6 +1186,11 @@ export class MessageListView {this._rerender_message(message_container, false, true);}+ hide_revealed_message(message_id) {+ const message_container = this.message_containers.get(message_id);+ this._rerender_message(message_container, false, false);+ }+rerender_messages(messages, message_content_edited) {// Convert messages to list messageslet message_containers = messages.map((message) => this.message_containers.get(message.id));diff --git a/static/js/popovers.js b/static/js/popovers.jsindex 1c183a710a1..6cfd8992574 100644--- a/static/js/popovers.js+++ b/static/js/popovers.js@@ -524,6 +524,8 @@ export function toggle_actions_popover(element, id) {const elt = $(element);if (elt.data("popover") === undefined) {const message = message_lists.current.get(id);+ const message_container = message_lists.current.view.message_containers.get(message.id);+ const should_display_hide_option = !message_container.is_hidden;const editability = message_edit.get_editability(message);let use_edit_icon;let editability_menu_item;@@ -582,6 +584,7 @@ export function toggle_actions_popover(element, id) {should_display_uncollapse,should_display_add_reaction_option: message.sent_by_me,should_display_edit_history_option,+ should_display_hide_option,conversation_time_uri,narrowed: narrow_state.active(),should_display_delete_option,@@ -1249,6 +1252,21 @@ export function register_click_handlers() {e.stopPropagation();e.preventDefault();});+ $("body").on("click", ".rehide_muted_user_message", (e) => {+ const message_id = $(e.currentTarget).data("message-id");+ const row = message_lists.current.get_row(message_id);+ const message = message_lists.current.get(rows.id(row));+ const message_container = message_lists.current.view.message_containers.get(message.id);++ hide_actions_popover();++ if (row && !message_container.is_hidden) {+ message_lists.current.view.hide_revealed_message(message_id);+ }++ e.stopPropagation();+ e.preventDefault();+ });$("body").on("click", ".view_edit_history", (e) => {const message_id = $(e.currentTarget).data("message-id");const row = message_lists.current.get_row(message_id);diff --git a/static/templates/actions_popover_content.hbs b/static/templates/actions_popover_content.hbsindex 92963ee90a5..d3fa5970637 100644--- a/static/templates/actions_popover_content.hbs+++ b/static/templates/actions_popover_content.hbs@@ -1,5 +1,14 @@{{! Contents of the "message actions" popup }}<ul class="nav nav-list actions_popover">+ {{#if should_display_hide_option}}+ <li>+ <a href="#" class="rehide_muted_user_message" data-message-id="{{message_id}}">+ <i class="fa fa-eye-slash" aria-hidden="true"></i>+ {{t "Hide muted message again" }}+ </a>+ </li>+ {{/if}}+{{#if should_display_edit_and_view_source}}<li><a href="#" class="popover_edit_message" data-message-id="{{message_id}}">