mirror of https://github.com/zulip/zulip.git
Avoid error in closest_id().
If we get a potential_idx that is not in items, we now just warn about it instead of letting a type error happen.
This commit is contained in:
parent
42af09663d
commit
081e0405dc
|
@ -288,7 +288,14 @@ exports.MessageList.prototype = {
|
||||||
if (potential_idx < 0) {
|
if (potential_idx < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var potential_match = items[potential_idx].id;
|
var item = items[potential_idx];
|
||||||
|
|
||||||
|
if (item === undefined) {
|
||||||
|
blueslip.warn('Invalid potential_idx: ' + potential_idx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var potential_match = item.id;
|
||||||
// If the potential id is the closest to the requested, save that one
|
// If the potential id is the closest to the requested, save that one
|
||||||
if (Math.abs(id - potential_match) < Math.abs(best_match - id)) {
|
if (Math.abs(id - potential_match) < Math.abs(best_match - id)) {
|
||||||
best_match = potential_match;
|
best_match = potential_match;
|
||||||
|
|
Loading…
Reference in New Issue