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_topics: Improve code level documentation.

Aman Agrawal347c0dc80f06
diff --git a/static/js/recent_topics.js b/static/js/recent_topics.js
index 3281f7b55c3..fb222d515e5 100644
--- a/static/js/recent_topics.js
+++ b/static/js/recent_topics.js
@@ -227,19 +227,30 @@ exports.update_topic_unread_count = function (message) {
};
exports.set_filter = function (filter) {
+ // This function updates the `filters` variable
+ // after user clicks on one of the filter buttons
+ // based on `btn-recent-selected` class and current
+ // set `filters`.
+
+ // Get the button which was clicked.
const filter_elem = $('#recent_topics_filter_buttons')
.find('[data-filter="' + filter + '"]');
+ // If user clicks `All`, we clear all filters.
if (filter === 'all' && filters.size !== 0) {
filters = new Set();
+ // If the button was already selected, remove the filter.
} else if (filter_elem.hasClass('btn-recent-selected')) {
filters.delete(filter);
+ // If the button was not selected, we add the filter.
} else {
filters.add(filter);
}
};
function show_selected_filters() {
+ // Add `btn-selected-filter` to the buttons to show
+ // which filters are applied.
if (filters.size === 0) {
$('#recent_topics_filter_buttons')
.find('[data-filter="all"]')
@@ -292,7 +303,7 @@ exports.complete_rerender = function () {
if (!overlays.recent_topics_open()) {
return false;
}
- // Prepare Header
+ // Prepare header
const rendered_body = render_recent_topics_body({
filter_participated: filters.has('participated'),
filter_unread: filters.has('unread'),