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.

stream_list: Convert build_stream_sidebar_row to an ES6 class.

Anders Kaseorge47fd521e38f
diff --git a/static/js/stream_list.js b/static/js/stream_list.js
index 6f4b5d01a99..99e1e72eed8 100644
--- a/static/js/stream_list.js
+++ b/static/js/stream_list.js
@@ -230,34 +230,37 @@ function build_stream_sidebar_li(sub) {
return list_item;
}
-function build_stream_sidebar_row(sub) {
- const self = {};
- const list_item = build_stream_sidebar_li(sub);
+class StreamSidebarRow {
+ constructor(sub) {
+ this.sub = sub;
+ this.list_item = build_stream_sidebar_li(sub);
+ this.update_unread_count();
+ }
- self.update_whether_active = function () {
- if (stream_data.is_active(sub) || sub.pin_to_top === true) {
- list_item.removeClass("inactive_stream");
+ update_whether_active() {
+ if (stream_data.is_active(this.sub) || this.sub.pin_to_top === true) {
+ this.list_item.removeClass("inactive_stream");
} else {
- list_item.addClass("inactive_stream");
+ this.list_item.addClass("inactive_stream");
}
- };
-
- self.get_li = function () {
- return list_item;
- };
+ }
- self.remove = function () {
- list_item.remove();
- };
+ get_li() {
+ return this.list_item;
+ }
- self.update_unread_count = function () {
- const count = unread.num_unread_for_stream(sub.stream_id);
- exports.update_count_in_dom(list_item, count);
- };
+ remove() {
+ this.list_item.remove();
+ }
- self.update_unread_count();
+ update_unread_count() {
+ const count = unread.num_unread_for_stream(this.sub.stream_id);
+ exports.update_count_in_dom(this.list_item, count);
+ }
+}
- exports.stream_sidebar.set_row(sub.stream_id, self);
+function build_stream_sidebar_row(sub) {
+ exports.stream_sidebar.set_row(sub.stream_id, new StreamSidebarRow(sub));
}
exports.create_sidebar_row = function (sub) {