mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +00:00
js: Avoid _.first, _.last, _.initial, _.tail.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
committed by
Tim Abbott
parent
42931e69e6
commit
cc40352541
@@ -397,7 +397,7 @@ export class MessageListData {
|
|||||||
} else {
|
} else {
|
||||||
// Any of the ids that we skipped over (due to them being local-only) might be the
|
// Any of the ids that we skipped over (due to them being local-only) might be the
|
||||||
// closest ID to the desired one, in case there is no exact match.
|
// closest ID to the desired one, in case there is no exact match.
|
||||||
potential_closest_matches.unshift(_.last(potential_closest_matches) - 1);
|
potential_closest_matches.unshift(closest - 1);
|
||||||
let best_match = items[closest].id;
|
let best_match = items[closest].id;
|
||||||
|
|
||||||
for (const potential_idx of potential_closest_matches) {
|
for (const potential_idx of potential_closest_matches) {
|
||||||
|
|||||||
@@ -437,8 +437,8 @@ export class MessageListView {
|
|||||||
if (first_group === undefined || second_group === undefined) {
|
if (first_group === undefined || second_group === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const last_msg_container = _.last(first_group.message_containers);
|
const last_msg_container = first_group.message_containers.at(-1);
|
||||||
const first_msg_container = _.first(second_group.message_containers);
|
const first_msg_container = second_group.message_containers[0];
|
||||||
|
|
||||||
// Join two groups into one.
|
// Join two groups into one.
|
||||||
if (
|
if (
|
||||||
@@ -498,19 +498,19 @@ export class MessageListView {
|
|||||||
let prev_msg_container;
|
let prev_msg_container;
|
||||||
|
|
||||||
if (where === "top") {
|
if (where === "top") {
|
||||||
first_group = _.last(new_message_groups);
|
first_group = new_message_groups.at(-1);
|
||||||
second_group = _.first(this._message_groups);
|
second_group = this._message_groups[0];
|
||||||
} else {
|
} else {
|
||||||
first_group = _.last(this._message_groups);
|
first_group = this._message_groups.at(-1);
|
||||||
second_group = _.first(new_message_groups);
|
second_group = new_message_groups[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first_group) {
|
if (first_group) {
|
||||||
prev_msg_container = _.last(first_group.message_containers);
|
prev_msg_container = first_group.message_containers.at(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (second_group) {
|
if (second_group) {
|
||||||
curr_msg_container = _.first(second_group.message_containers);
|
curr_msg_container = second_group.message_containers[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
const was_joined = this.join_message_groups(first_group, second_group);
|
const was_joined = this.join_message_groups(first_group, second_group);
|
||||||
@@ -536,7 +536,7 @@ export class MessageListView {
|
|||||||
this._message_groups.shift();
|
this._message_groups.shift();
|
||||||
this._message_groups.unshift(first_group);
|
this._message_groups.unshift(first_group);
|
||||||
|
|
||||||
new_message_groups = _.initial(new_message_groups);
|
new_message_groups = new_message_groups.slice(0, -1);
|
||||||
} else if (
|
} else if (
|
||||||
!same_day(second_group.message_containers[0], first_group.message_containers[0])
|
!same_day(second_group.message_containers[0], first_group.message_containers[0])
|
||||||
) {
|
) {
|
||||||
@@ -551,8 +551,8 @@ export class MessageListView {
|
|||||||
if (was_joined) {
|
if (was_joined) {
|
||||||
// rerender the last message
|
// rerender the last message
|
||||||
message_actions.rerender_messages_next_same_sender.push(prev_msg_container);
|
message_actions.rerender_messages_next_same_sender.push(prev_msg_container);
|
||||||
message_actions.append_messages = _.first(new_message_groups).message_containers;
|
message_actions.append_messages = new_message_groups[0].message_containers;
|
||||||
new_message_groups = _.tail(new_message_groups);
|
new_message_groups = new_message_groups.slice(1);
|
||||||
} else if (first_group !== undefined && second_group !== undefined) {
|
} else if (first_group !== undefined && second_group !== undefined) {
|
||||||
if (same_day(prev_msg_container, curr_msg_container)) {
|
if (same_day(prev_msg_container, curr_msg_container)) {
|
||||||
clear_group_date_divider(second_group);
|
clear_group_date_divider(second_group);
|
||||||
@@ -825,11 +825,10 @@ export class MessageListView {
|
|||||||
|
|
||||||
restore_scroll_position();
|
restore_scroll_position();
|
||||||
|
|
||||||
const last_message_group = _.last(this._message_groups);
|
const last_message_group = this._message_groups.at(-1);
|
||||||
if (last_message_group !== undefined) {
|
if (last_message_group !== undefined) {
|
||||||
list.last_message_historical = _.last(
|
list.last_message_historical =
|
||||||
last_message_group.message_containers,
|
last_message_group.message_containers.at(-1).msg.historical;
|
||||||
).msg.historical;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const stream_name = narrow_state.stream();
|
const stream_name = narrow_state.stream();
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
import _ from "lodash";
|
|
||||||
|
|
||||||
import * as emoji from "../shared/js/emoji";
|
import * as emoji from "../shared/js/emoji";
|
||||||
import render_message_reaction from "../templates/message_reaction.hbs";
|
import render_message_reaction from "../templates/message_reaction.hbs";
|
||||||
@@ -172,8 +171,8 @@ function generate_title(emoji_name, user_ids) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.comma_separated_usernames = _.initial(usernames).join(", ");
|
context.comma_separated_usernames = usernames.slice(0, -1).join(", ");
|
||||||
context.last_username = _.last(usernames);
|
context.last_username = usernames.at(-1);
|
||||||
if (current_user_reacted) {
|
if (current_user_reacted) {
|
||||||
return $t(
|
return $t(
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user