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.

recent_view: Add table header to sort by unread count.

Aman Agrawalaaf3369d394a
diff --git a/web/shared/icons/unread.svg b/web/shared/icons/unread.svg
new file mode 100644
index 00000000000..99be0268bae
--- /dev/null
+++ b/web/shared/icons/unread.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M16.1 3C16.0344 3.32311 16 3.65753 16 4C16 4.34247 16.0344 4.67689 16.1 5H4.51146L12.0619 11.662L17.1098 7.14141C17.5363 7.66888 18.0679 8.10787 18.6728 8.42652L12.0718 14.338L4 7.21594V19H20V8.89998C20.3231 8.96557 20.6575 9 21 9C21.3425 9 21.6769 8.96557 22 8.89998V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H16.1ZM21 1C22.6569 1 24 2.34315 24 4C24 5.65685 22.6569 7 21 7C19.3431 7 18 5.65685 18 4C18 2.34315 19.3431 1 21 1Z"></path></svg>
\ No newline at end of file
diff --git a/web/src/recent_view_ui.js b/web/src/recent_view_ui.js
index 7af07ccd2e2..da9d6bbc85d 100644
--- a/web/src/recent_view_ui.js
+++ b/web/src/recent_view_ui.js
@@ -758,6 +758,20 @@ function topic_sort(a, b) {
return sort_comparator(topic_sort_key(a), topic_sort_key(b));
}
+function unread_count(conversation_data) {
+ const message = message_store.get(conversation_data.last_msg_id);
+ return message_to_conversation_unread_count(message);
+}
+
+function unread_sort(a, b) {
+ const a_unread_count = unread_count(a);
+ const b_unread_count = unread_count(b);
+ if (a_unread_count !== b_unread_count) {
+ return a_unread_count - b_unread_count;
+ }
+ return a.last_msg_id - b.last_msg_id;
+}
+
function topic_offset_to_visible_area(topic_row) {
const $topic_row = $(topic_row);
if ($topic_row.length === 0) {
@@ -880,6 +894,7 @@ export function complete_rerender() {
sort_fields: {
stream_sort,
topic_sort,
+ unread_sort,
...ListWidget.generic_sort_functions("numeric", ["last_msg_id"]),
},
html_selector: get_topic_row,
diff --git a/web/styles/recent_view.css b/web/styles/recent_view.css
index 8750189f062..02d36d2b92e 100644
--- a/web/styles/recent_view.css
+++ b/web/styles/recent_view.css
@@ -104,6 +104,19 @@
text-align: left;
}
+ .unread_sort {
+ .zulip-icon-unread {
+ position: absolute;
+ right: 30px;
+ top: 11px;
+ }
+
+ &::after {
+ right: 15px;
+ top: 7px;
+ }
+ }
+
td {
border-top: 1px solid hsl(0deg 0% 87%);
}
diff --git a/web/templates/recent_view_row.hbs b/web/templates/recent_view_row.hbs
index ca61fa598e6..cabe6fdbb87 100644
--- a/web/templates/recent_view_row.hbs
+++ b/web/templates/recent_view_row.hbs
@@ -28,7 +28,7 @@
{{/if}}
</div>
</td>
- <td class="recent_topic_name">
+ <td class="recent_topic_name" colspan="2">
<div class="flex_container">
<div class="left_part recent_view_focusable line_clamp">
{{#if is_private}}
diff --git a/web/templates/recent_view_table.hbs b/web/templates/recent_view_table.hbs
index 2762b11bc9a..e89189b7046 100644
--- a/web/templates/recent_view_table.hbs
+++ b/web/templates/recent_view_table.hbs
@@ -15,6 +15,9 @@
<tr>
<th data-sort="stream_sort">{{t 'Stream' }}</th>
<th data-sort="topic_sort">{{t 'Topic' }}</th>
+ <th data-sort="unread_sort" class="unread_sort">
+ <i class="zulip-icon zulip-icon-unread"></i>
+ </th>
<th class='participants_header'>{{t 'Participants' }}</th>
<th data-sort="numeric" data-sort-prop="last_msg_id" class="last_msg_time_header active descend">{{t 'Time' }}</th>
</tr>