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 stream_sidebar to an ES6 class StreamSidebar.

Anders Kaseorg2aae92b6e3cc
diff --git a/static/js/stream_list.js b/static/js/stream_list.js
index da60ad38058..6f4b5d01a99 100644
--- a/static/js/stream_list.js
+++ b/static/js/stream_list.js
@@ -24,35 +24,32 @@ exports.update_count_in_dom = function (unread_count_elem, count) {
value_span.text(count);
};
-exports.stream_sidebar = (function () {
- const self = {};
-
- self.rows = new Map(); // stream id -> row widget
+class StreamSidebar {
+ rows = new Map(); // stream id -> row widget
- self.set_row = function (stream_id, widget) {
- self.rows.set(stream_id, widget);
- };
+ set_row(stream_id, widget) {
+ this.rows.set(stream_id, widget);
+ }
- self.get_row = function (stream_id) {
- return self.rows.get(stream_id);
- };
+ get_row(stream_id) {
+ return this.rows.get(stream_id);
+ }
- self.has_row_for = function (stream_id) {
- return self.rows.has(stream_id);
- };
+ has_row_for(stream_id) {
+ return this.rows.has(stream_id);
+ }
- self.remove_row = function (stream_id) {
+ remove_row(stream_id) {
// This only removes the row from our data structure.
// Our caller should use build_stream_list() to re-draw
// the sidebar, so that we don't have to deal with edge
// cases like removing the last pinned stream (and removing
// the divider).
- self.rows.delete(stream_id);
- };
-
- return self;
-})();
+ this.rows.delete(stream_id);
+ }
+}
+exports.stream_sidebar = new StreamSidebar();
function get_search_term() {
const search_box = $(".stream-list-filter");