status_emoji: Show status emoji in single PMs in the PM list.

Previously the emoji_status set by the user would only be seen in the
buddy list, it was decided that it would be useful to show the
emoji_status in other places as well.

As such this commit uses the status_emoji template to show the status
emoji in the PM list and also implements live update behavior.

With refactor and minor edits by Yash RE.

Co-authored-by: YashRE42 <33805964+YashRE42@users.noreply.github.com>
This commit is contained in:
AnushaNathRoy
2022-02-05 23:40:59 +05:30
committed by YashRE42
parent fdabf0b357
commit e1fd47a692
4 changed files with 34 additions and 1 deletions

View File

@@ -19,6 +19,12 @@ mock_esm("../../static/js/stream_popover", {
mock_esm("../../static/js/ui", {
get_content_element: (element) => element,
});
mock_esm("../../static/js/user_status", {
is_away: () => false,
get_status_emoji: () => ({
emoji_code: 20,
}),
});
const people = zrequire("people");
const pm_conversations = zrequire("pm_conversations");
@@ -72,7 +78,7 @@ test("close", () => {
test("build_private_messages_list", ({override}) => {
const timestamp = 0;
pm_conversations.recent.insert([101, 102], timestamp);
pm_conversations.recent.insert([103], timestamp);
let num_unread_for_person = 1;
override(unread, "num_unread_for_person", () => num_unread_for_person);
@@ -86,6 +92,19 @@ test("build_private_messages_list", ({override}) => {
pm_list._build_private_messages_list();
const expected_data = [
{
is_active: false,
is_group: false,
is_zero: false,
recipients: "Me Myself",
unread: 1,
url: "#narrow/pm-with/103-me",
user_circle_class: "user_circle_empty",
user_ids_string: "103",
status_emoji_info: {
emoji_code: 20,
},
},
{
recipients: "Alice, Bob",
user_ids_string: "101,102",
@@ -95,6 +114,7 @@ test("build_private_messages_list", ({override}) => {
url: "#narrow/pm-with/101,102-group",
user_circle_class: undefined,
is_group: true,
status_emoji_info: undefined,
},
];
@@ -104,6 +124,8 @@ test("build_private_messages_list", ({override}) => {
pm_list._build_private_messages_list();
expected_data[0].unread = 0;
expected_data[0].is_zero = true;
expected_data[1].unread = 0;
expected_data[1].is_zero = true;
assert.deepEqual(pm_data, expected_data);
pm_list._build_private_messages_list();
@@ -133,6 +155,7 @@ test("build_private_messages_list_bot", ({override}) => {
is_zero: false,
is_active: false,
url: "#narrow/pm-with/314-outgoingwebhook",
status_emoji_info: undefined,
user_circle_class: "user_circle_green",
is_group: false,
},
@@ -144,6 +167,7 @@ test("build_private_messages_list_bot", ({override}) => {
is_active: false,
url: "#narrow/pm-with/101,102-group",
user_circle_class: undefined,
status_emoji_info: undefined,
is_group: true,
},
];