Skip to content

Commit

Permalink
Revert "message_reactions: Clean meassge reactions during initial pro…
Browse files Browse the repository at this point in the history
…cessing."

This reverts commit c22a94d.

This broke live-update when adding new reactions.
  • Loading branch information
timabbott committed Apr 15, 2024
1 parent b0e3191 commit 3df46d5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
13 changes: 3 additions & 10 deletions web/src/message_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as message_store from "./message_store";
import * as message_user_ids from "./message_user_ids";
import * as people from "./people";
import * as pm_conversations from "./pm_conversations";
import * as reactions from "./reactions";
import * as recent_senders from "./recent_senders";
import * as stream_topic_history from "./stream_topic_history";
import * as user_status from "./user_status";
Expand All @@ -24,17 +23,9 @@ export function process_new_message(message) {
return cached_msg;
}

if (!message.reactions) {
message.reactions = [];
}

message_store.set_message_booleans(message);
message.sent_by_me = people.is_current_user(message.sender_email);

// Cleaning message_reactions during initial message processing
// to avoid message_reactions being undefined during rendering
message.message_reactions = reactions.get_message_reactions(message);

people.extract_people_from_message(message);
people.maybe_incr_recipient_count(message);

Expand Down Expand Up @@ -83,7 +74,9 @@ export function process_new_message(message) {
}

alert_words.process_message(message);

if (!message.reactions) {
message.reactions = [];
}
message_store.update_message_cache(message);
return message;
}
5 changes: 5 additions & 0 deletions web/src/message_list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import * as narrow_state from "./narrow_state";
import {page_params} from "./page_params";
import * as people from "./people";
import * as popovers from "./popovers";
import * as reactions from "./reactions";
import * as rendered_markdown from "./rendered_markdown";
import * as rows from "./rows";
import * as sidebar_ui from "./sidebar_ui";
Expand Down Expand Up @@ -524,6 +525,8 @@ export class MessageListView {
};

for (const message_container of message_containers) {
const message_reactions = reactions.get_message_reactions(message_container.msg);
message_container.msg.message_reactions = message_reactions;
message_container.include_recipient = false;

if (
Expand Down Expand Up @@ -775,6 +778,8 @@ export class MessageListView {
}

_get_message_template(message_container) {
const msg_reactions = reactions.get_message_reactions(message_container.msg);
message_container.msg.message_reactions = msg_reactions;
const msg_to_render = {
...message_container,
message_list_id: this.list.id,
Expand Down
2 changes: 0 additions & 2 deletions web/tests/dispatch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ people.add_active_user(me);
people.add_active_user(test_user);
people.initialize_current_user(me.user_id);

// process_new_messages calls get_message_reactions, so we need to stub it.
reactions.get_message_reactions = (message) => message.reactions;
message_helper.process_new_message(test_message);

const realm_emoji = {};
Expand Down
3 changes: 1 addition & 2 deletions web/tests/message_events.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ run_test("update_messages", () => {
{
alerted: false,
collapsed: false,
clean_reactions: new Map(),
content: "<b>new content</b>",
display_recipient: denmark.name,
historical: false,
Expand All @@ -135,8 +134,8 @@ run_test("update_messages", () => {
stream_wildcard_mentioned: false,
topic_wildcard_mentioned: false,
mentioned_me_directly: false,
message_reactions: [],
raw_content: "**new content**",
reactions: [],
reply_to: alice.email,
sender_email: alice.email,
sender_full_name: alice.full_name,
Expand Down

0 comments on commit 3df46d5

Please sign in to comment.