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.

top_left_corner: Directly use `span.unread_count` to display unreads.

Aman Agrawal84afc67369b2
diff --git a/frontend_tests/node_tests/pm_list.js b/frontend_tests/node_tests/pm_list.js
index bd991c6f150..ecb0c38bd53 100644
--- a/frontend_tests/node_tests/pm_list.js
+++ b/frontend_tests/node_tests/pm_list.js
@@ -160,18 +160,16 @@ test("update_dom_with_unread_counts", (override) => {
override(narrow_state, "active", () => true);
- const total_value = $.create("total-value-stub");
const total_count = $.create("total-count-stub");
const private_li = $(".top_left_private_messages");
- private_li.set_find_results(".count", total_count);
- total_count.set_find_results(".value", total_value);
+ private_li.set_find_results(".unread_count", total_count);
counts = {
private_message_count: 10,
};
pm_list.update_dom_with_unread_counts(counts);
- assert.equal(total_value.text(), "10");
+ assert.equal(total_count.text(), "10");
assert(total_count.visible());
counts = {
@@ -179,7 +177,7 @@ test("update_dom_with_unread_counts", (override) => {
};
pm_list.update_dom_with_unread_counts(counts);
- assert.equal(total_value.text(), "");
+ assert.equal(total_count.text(), "");
assert(!total_count.visible());
});
diff --git a/frontend_tests/node_tests/stream_list.js b/frontend_tests/node_tests/stream_list.js
index 26ca171ac83..2e13cff773d 100644
--- a/frontend_tests/node_tests/stream_list.js
+++ b/frontend_tests/node_tests/stream_list.js
@@ -49,13 +49,11 @@ const social = {
let num_unread_for_stream;
function create_devel_sidebar_row() {
- const devel_value = $.create("devel-value");
const devel_count = $.create("devel-count");
const sidebar_row = $("<devel sidebar row>");
- sidebar_row.set_find_results(".count", devel_count);
- devel_count.set_find_results(".value", devel_value);
+ sidebar_row.set_find_results(".unread_count", devel_count);
devel_count.set_parent(sidebar_row);
stub_templates((template_name, data) => {
@@ -66,16 +64,14 @@ function create_devel_sidebar_row() {
num_unread_for_stream = 42;
stream_list.create_sidebar_row(devel);
- assert.equal(devel_value.text(), "42");
+ assert.equal(devel_count.text(), "42");
}
function create_social_sidebar_row() {
- const social_value = $.create("social-value");
const social_count = $.create("social-count");
const sidebar_row = $("<social sidebar row>");
- sidebar_row.set_find_results(".count", social_count);
- social_count.set_find_results(".value", social_value);
+ sidebar_row.set_find_results(".unread_count", social_count);
social_count.set_parent(sidebar_row);
stub_templates((template_name, data) => {
@@ -86,7 +82,7 @@ function create_social_sidebar_row() {
num_unread_for_stream = 99;
stream_list.create_sidebar_row(social);
- assert.equal(social_value.text(), "99");
+ assert.equal(social_count.text(), "99");
}
function test_ui(label, f) {
@@ -587,17 +583,15 @@ test_ui("separators_only_pinned", () => {
});
test_ui("update_count_in_dom", () => {
- function make_elem(elem, count_selector, value_selector) {
+ function make_elem(elem, count_selector) {
const count = $(count_selector);
- const value = $(value_selector);
- elem.set_find_results(".count", count);
- count.set_find_results(".value", value);
+ elem.set_find_results(".unread_count", count);
count.set_parent(elem);
return elem;
}
- const stream_li = make_elem($("<stream li>"), "<stream-count>", "<stream-value>");
+ const stream_li = make_elem($("<stream li>"), "<stream-count>");
$("<stream li>").length = 0;
stream_li.addClass("subscription_block");
@@ -628,7 +622,7 @@ test_ui("update_count_in_dom", () => {
stream_count.set(stream_id, 99);
stream_list.update_dom_with_unread_counts(counts);
- assert.equal($("<stream-value>").text(), "99");
+ assert.equal($("<stream-count>").text(), "99");
assert(stream_li.hasClass("stream-with-count"));
});
diff --git a/frontend_tests/node_tests/top_left_corner.js b/frontend_tests/node_tests/top_left_corner.js
index 21e821b33f8..d2c4bc9a55b 100644
--- a/frontend_tests/node_tests/top_left_corner.js
+++ b/frontend_tests/node_tests/top_left_corner.js
@@ -99,11 +99,9 @@ run_test("narrowing", (override) => {
});
run_test("update_count_in_dom", () => {
- function make_elem(elem, count_selector, value_selector) {
+ function make_elem(elem, count_selector) {
const count = $(count_selector);
- const value = $(value_selector);
- elem.set_find_results(".count", count);
- count.set_find_results(".value", value);
+ elem.set_find_results(".unread_count", count);
count.set_parent(elem);
return elem;
@@ -114,24 +112,24 @@ run_test("update_count_in_dom", () => {
home_unread_messages: 333,
};
- make_elem($(".top_left_mentions"), "<mentioned-count>", "<mentioned-value>");
+ make_elem($(".top_left_mentions"), "<mentioned-count>");
- make_elem($(".top_left_all_messages"), "<home-count>", "<home-value>");
+ make_elem($(".top_left_all_messages"), "<home-count>");
- make_elem($(".top_left_starred_messages"), "<starred-count>", "<starred-value>");
+ make_elem($(".top_left_starred_messages"), "<starred-count>");
top_left_corner.update_dom_with_unread_counts(counts);
top_left_corner.update_starred_count(444);
- assert.equal($("<mentioned-value>").text(), "222");
- assert.equal($("<home-value>").text(), "333");
- assert.equal($("<starred-value>").text(), "444");
+ assert.equal($("<mentioned-count>").text(), "222");
+ assert.equal($("<home-count>").text(), "333");
+ assert.equal($("<starred-count>").text(), "444");
counts.mentioned_message_count = 0;
top_left_corner.update_dom_with_unread_counts(counts);
top_left_corner.update_starred_count(0);
assert(!$("<mentioned-count>").visible());
- assert.equal($("<mentioned-value>").text(), "");
- assert.equal($("<starred-value>").text(), "");
+ assert.equal($("<mentioned-count>").text(), "");
+ assert.equal($("<starred-count>").text(), "");
});
diff --git a/static/js/pm_list.js b/static/js/pm_list.js
index 8a2f02e308d..98b258814af 100644
--- a/static/js/pm_list.js
+++ b/static/js/pm_list.js
@@ -8,9 +8,9 @@ import * as pm_conversations from "./pm_conversations";
import * as pm_list_dom from "./pm_list_dom";
import * as stream_popover from "./stream_popover";
import * as ui from "./ui";
+import * as ui_util from "./ui_util";
import * as unread from "./unread";
import * as vdom from "./vdom";
-import * as ui_util from "./ui_util";
let prior_dom;
let private_messages_open = false;
diff --git a/static/js/top_left_corner.js b/static/js/top_left_corner.js
index 3b03e6bce8e..6325586cc56 100644
--- a/static/js/top_left_corner.js
+++ b/static/js/top_left_corner.js
@@ -3,8 +3,8 @@ import $ from "jquery";
import * as people from "./people";
import * as pm_list from "./pm_list";
import * as resize from "./resize";
-import * as unread_ui from "./unread_ui";
import * as ui_util from "./ui_util";
+import * as unread_ui from "./unread_ui";
export function update_starred_count(count) {
const starred_li = $(".top_left_starred_messages");
diff --git a/static/js/ui_util.js b/static/js/ui_util.js
index 0bfa49f6a83..cdfbf9a2a64 100644
--- a/static/js/ui_util.js
+++ b/static/js/ui_util.js
@@ -42,15 +42,14 @@ export function convert_enter_to_click(e) {
export function update_unread_count_in_dom(unread_count_elem, count) {
// This function is used to update unread count in top left corner
// elements.
- const count_span = unread_count_elem.find(".count");
- const value_span = count_span.find(".value");
+ const unread_count_span = unread_count_elem.find(".unread_count");
if (count === 0) {
- count_span.hide();
- value_span.text("");
+ unread_count_span.hide();
+ unread_count_span.text("");
return;
}
- count_span.show();
- value_span.text(count);
+ unread_count_span.show();
+ unread_count_span.text(count);
}
diff --git a/static/styles/app_components.css b/static/styles/app_components.css
index 8e41f0fb624..97304d99029 100644
--- a/static/styles/app_components.css
+++ b/static/styles/app_components.css
@@ -477,3 +477,20 @@ div.overlay {
.tip::before {
content: "\f0a2";
}
+
+/* We are mostly consistent in how we style
+ unread counts, except for starred messages.
+ This is the common section.
+*/
+.unread_count {
+ float: right;
+ padding: 0 4px;
+ height: 16px;
+ line-height: 16px;
+ font-size: 12px;
+ font-weight: normal;
+ letter-spacing: 0.6px;
+ border-radius: 4px;
+ background-color: hsl(105, 2%, 50%);
+ color: hsl(0, 0%, 100%);
+}
diff --git a/static/styles/left_sidebar.css b/static/styles/left_sidebar.css
index 17ce10ae660..440e0797100 100644
--- a/static/styles/left_sidebar.css
+++ b/static/styles/left_sidebar.css
@@ -233,7 +233,7 @@ li.active-sub-filter {
text-align: center;
}
- .count {
+ .top_left_row .unread_count {
margin-right: 20px;
margin-top: 2px;
display: none;
@@ -289,14 +289,6 @@ li.top_left_recent_topics {
font-size: 13px;
}
-/* We are mostly consistent in how we style
- unread counts, except for starred messages.
- This is the common section.
-*/
-.top_left_all_messages .count,
-.top_left_private_messages .count,
-.top_left_starred_messages .count,
-.top_left_mentions .count,
#stream_filters .count,
.topic-unread-count,
.private_message_count {
@@ -321,9 +313,6 @@ li.top_left_recent_topics {
}
/* These are true "unread" counts. */
-.top_left_all_messages .count,
-.top_left_private_messages .count,
-.top_left_mentions .count,
#stream_filters .count,
.topic-unread-count,
.private_message_count {
diff --git a/templates/zerver/app/left_sidebar.html b/templates/zerver/app/left_sidebar.html
index e06e37374da..8baccbb01ae 100644
--- a/templates/zerver/app/left_sidebar.html
+++ b/templates/zerver/app/left_sidebar.html
@@ -9,9 +9,7 @@
</span>
{#- squash whitespace -#}
<span>{{ _('All messages') }}</span>
- <span class="count">
- <span class="value"></span>
- </span>
+ <span class="unread_count"></span>
</a>
<span class="arrow all-messages-sidebar-menu-icon"><i class="zulip-icon ellipsis-v-solid" aria-hidden="true"></i></span>
</li>
@@ -23,9 +21,7 @@
</span>
{#- squash whitespace -#}
<span>{{ _('Private messages') }}</span>
- <span class="count">
- <span class="value"></span>
- </span>
+ <span class="unread_count"></span>
</a>
</div>
<div id="private-container" class="scrolling_list" data-simplebar>
@@ -38,9 +34,7 @@
</span>
{#- squash whitespace -#}
<span>{{ _('Mentions') }}</span>
- <span class="count">
- <span class="value"></span>
- </span>
+ <span class="unread_count"></span>
</a>
</li>
<li class="top_left_starred_messages top_left_row">
@@ -50,9 +44,7 @@
</span>
{#- squash whitespace -#}
<span>{{ _('Starred messages') }}</span>
- <span class="count">
- <span class="value"></span>
- </span>
+ <span class="unread_count"></span>
</a>
<span class="arrow starred-messages-sidebar-menu-icon"><i class="zulip-icon ellipsis-v-solid" aria-hidden="true"></i></span>
</li>