Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_list_view: Simplify type of mention_classname.

evykassirerc19b3b0826a1
diff --git a/web/src/message_list_view.ts b/web/src/message_list_view.ts
index 5218108b437..a40491e8ffc 100644
--- a/web/src/message_list_view.ts
+++ b/web/src/message_list_view.ts
@@ -53,7 +53,7 @@ export type MessageContainer = {
include_sender: boolean;
is_hidden: boolean;
last_edit_timestr: string | undefined;
- mention_classname: string | null;
+ mention_classname: string | undefined;
message_edit_notices_in_left_col: boolean;
message_edit_notices_alongside_sender: boolean;
message_edit_notices_for_status_message: boolean;
@@ -653,7 +653,7 @@ export class MessageListView {
sender_is_guest: boolean;
should_add_guest_indicator_for_sender: boolean;
is_hidden: boolean;
- mention_classname?: string | null;
+ mention_classname: string | undefined;
include_sender: boolean;
status_message: string | false;
last_edit_timestr: string | undefined;
@@ -704,14 +704,14 @@ export class MessageListView {
stream_data.is_user_subscribed(message.stream_id, people.my_current_user_id())
) {
mention_classname = "direct_mention";
+ } else {
+ mention_classname = undefined;
}
} else {
mention_classname = "group_mention";
}
} else {
- // If there are no mentions, the classname might need to be updated (i.e.
- // removed) to reflect this.
- mention_classname = null;
+ mention_classname = undefined;
}
let include_sender = existing_include_sender && !is_hidden;
if (is_revealed) {
@@ -742,8 +742,7 @@ export class MessageListView {
sender_is_guest,
should_add_guest_indicator_for_sender,
is_hidden,
- // don't set this unless we found a new value for it.
- ...(mention_classname !== undefined && {mention_classname}),
+ mention_classname,
include_sender,
...this._maybe_get_me_message(is_hidden, message),
...this._get_message_edited_vars(message),
@@ -905,7 +904,6 @@ export class MessageListView {
...(pm_with_url && {pm_with_url}),
want_date_divider,
date_divider_html,
- mention_classname: null,
...calculated_variables,
...this.get_edited_notice_locations(
include_sender,
diff --git a/web/tests/message_list_view.test.js b/web/tests/message_list_view.test.js
index c436dd5b56d..4cdf881ab9d 100644
--- a/web/tests/message_list_view.test.js
+++ b/web/tests/message_list_view.test.js
@@ -402,7 +402,7 @@ test("muted_message_vars", () => {
// Additionally test that, both there is no mention classname even on that message
// which has a mention, since we don't want to display muted mentions so visibly.
- assert.equal(result[1].mention_classname, null);
+ assert.equal(result[1].mention_classname, undefined);
// Now, reveal the hidden messages.
let is_revealed = true;
@@ -435,7 +435,7 @@ test("muted_message_vars", () => {
// Additionally test that, both there is no mention classname even on that message
// which has a mention, since we don't want to display hidden mentions so visibly.
- assert.equal(result[1].mention_classname, null);
+ assert.equal(result[1].mention_classname, undefined);
})();
});