mirror of https://github.com/zulip/zulip.git
js: Convert _.chain to array methods.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
1fd4762063
commit
aa7df21265
|
@ -386,10 +386,9 @@ class Filter {
|
||||||
}
|
}
|
||||||
|
|
||||||
operands(operator) {
|
operands(operator) {
|
||||||
return _.chain(this._operators)
|
return this._operators
|
||||||
.filter((elem) => !elem.negated && elem.operator === operator)
|
.filter((elem) => !elem.negated && elem.operator === operator)
|
||||||
.map((elem) => elem.operand)
|
.map((elem) => elem.operand);
|
||||||
.value();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
has_negated_operand(operator, operand) {
|
has_negated_operand(operator, operand) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ function get_display_name(contributor) {
|
||||||
// - Display full name instead of GitHub username.
|
// - Display full name instead of GitHub username.
|
||||||
export default function render_tabs() {
|
export default function render_tabs() {
|
||||||
const template = _.template($("#contributors-template").html());
|
const template = _.template($("#contributors-template").html());
|
||||||
const total_tab_html = _.chain(contributors_list)
|
const total_tab_html = contributors_list
|
||||||
.map((c) => ({
|
.map((c) => ({
|
||||||
name: get_display_name(c),
|
name: get_display_name(c),
|
||||||
github_username: c.github_username,
|
github_username: c.github_username,
|
||||||
|
@ -68,10 +68,8 @@ export default function render_tabs() {
|
||||||
profile_url: get_profile_url(c),
|
profile_url: get_profile_url(c),
|
||||||
commits: calculate_total_commits(c),
|
commits: calculate_total_commits(c),
|
||||||
}))
|
}))
|
||||||
.sortBy("commits")
|
.sort((a, b) => (a.commits < b.commits ? 1 : a.commits > b.commits ? -1 : 0))
|
||||||
.reverse()
|
|
||||||
.map((c) => template(c))
|
.map((c) => template(c))
|
||||||
.value()
|
|
||||||
.join("");
|
.join("");
|
||||||
|
|
||||||
$("#tab-total").html(total_tab_html);
|
$("#tab-total").html(total_tab_html);
|
||||||
|
@ -86,10 +84,11 @@ export default function render_tabs() {
|
||||||
|
|
||||||
$("#" + tab_name).on("click", () => {
|
$("#" + tab_name).on("click", () => {
|
||||||
if (!loaded_repos.includes(repo_name)) {
|
if (!loaded_repos.includes(repo_name)) {
|
||||||
const html = _.chain(contributors_list)
|
const html = contributors_list
|
||||||
.filter(repo_name)
|
.filter((c) => c[repo_name])
|
||||||
.sortBy(repo_name)
|
.sort((a, b) =>
|
||||||
.reverse()
|
a[repo_name] < b[repo_name] ? 1 : a[repo_name] > b[repo_name] ? -1 : 0,
|
||||||
|
)
|
||||||
.map((c) =>
|
.map((c) =>
|
||||||
template({
|
template({
|
||||||
name: get_display_name(c),
|
name: get_display_name(c),
|
||||||
|
@ -99,7 +98,6 @@ export default function render_tabs() {
|
||||||
commits: c[repo_name],
|
commits: c[repo_name],
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.value()
|
|
||||||
.join("");
|
.join("");
|
||||||
|
|
||||||
$("#tab-" + tab_name).html(html);
|
$("#tab-" + tab_name).html(html);
|
||||||
|
|
|
@ -231,7 +231,10 @@ exports.initialize_kitchen_sink_stuff = function () {
|
||||||
selected_id_from_idx: messages[event.msg_list.selected_idx()].id,
|
selected_id_from_idx: messages[event.msg_list.selected_idx()].id,
|
||||||
msg_list_sorted: _.isEqual(
|
msg_list_sorted: _.isEqual(
|
||||||
messages.map((message) => message.id),
|
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,
|
found_in_dom: row_from_dom.length,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue