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.

js: Convert _.chain to array methods.

Anders Kaseorgaa7df21265fe
diff --git a/static/js/filter.js b/static/js/filter.js
index 5cce573d7bf..d9e651960c3 100644
--- a/static/js/filter.js
+++ b/static/js/filter.js
@@ -386,10 +386,9 @@ class Filter {
}
operands(operator) {
- return _.chain(this._operators)
+ return this._operators
.filter((elem) => !elem.negated && elem.operator === operator)
- .map((elem) => elem.operand)
- .value();
+ .map((elem) => elem.operand);
}
has_negated_operand(operator, operand) {
diff --git a/static/js/portico/team.js b/static/js/portico/team.js
index c158a4dcd6a..8a798a2511e 100644
--- a/static/js/portico/team.js
+++ b/static/js/portico/team.js
@@ -60,7 +60,7 @@ function get_display_name(contributor) {
// - Display full name instead of GitHub username.
export default function render_tabs() {
const template = _.template($("#contributors-template").html());
- const total_tab_html = _.chain(contributors_list)
+ const total_tab_html = contributors_list
.map((c) => ({
name: get_display_name(c),
github_username: c.github_username,
@@ -68,10 +68,8 @@ export default function render_tabs() {
profile_url: get_profile_url(c),
commits: calculate_total_commits(c),
}))
- .sortBy("commits")
- .reverse()
+ .sort((a, b) => (a.commits < b.commits ? 1 : a.commits > b.commits ? -1 : 0))
.map((c) => template(c))
- .value()
.join("");
$("#tab-total").html(total_tab_html);
@@ -86,10 +84,11 @@ export default function render_tabs() {
$("#" + tab_name).on("click", () => {
if (!loaded_repos.includes(repo_name)) {
- const html = _.chain(contributors_list)
- .filter(repo_name)
- .sortBy(repo_name)
- .reverse()
+ const html = contributors_list
+ .filter((c) => c[repo_name])
+ .sort((a, b) =>
+ a[repo_name] < b[repo_name] ? 1 : a[repo_name] > b[repo_name] ? -1 : 0,
+ )
.map((c) =>
template({
name: get_display_name(c),
@@ -99,7 +98,6 @@ export default function render_tabs() {
commits: c[repo_name],
}),
)
- .value()
.join("");
$("#tab-" + tab_name).html(html);
diff --git a/static/js/ui_init.js b/static/js/ui_init.js
index aa29d3d286c..e4c8266db52 100644
--- a/static/js/ui_init.js
+++ b/static/js/ui_init.js
@@ -231,7 +231,10 @@ exports.initialize_kitchen_sink_stuff = function () {
selected_id_from_idx: messages[event.msg_list.selected_idx()].id,
msg_list_sorted: _.isEqual(
messages.map((message) => message.id),
- _.chain(current_msg_list.all_messages()).pluck("id").clone().value().sort(),
+ current_msg_list
+ .all_messages()
+ .map((message) => message.id)
+ .sort(),
),
found_in_dom: row_from_dom.length,
});