buddy list: Remove stale jank from find_li.

It's clearer to return undefined than an empty list,
because it's easier to do an equality check for undefined
at call sites to this function.

`ListCursor.get_row` returns early for falsey values
returned from `find_li`, so I think whatever this
comment is referring to is no longer relevant.
This commit is contained in:
evykassirer 2024-02-21 13:39:32 -08:00 committed by Tim Abbott
parent be033394b1
commit 5db0f5f29a
1 changed files with 9 additions and 7 deletions

View File

@ -555,10 +555,12 @@ export class BuddyList extends BuddyListConf {
if (pos < this.render_count) { if (pos < this.render_count) {
this.render_count -= 1; this.render_count -= 1;
const $li = this.find_li({key: opts.user_id}); const $li = this.find_li({key: opts.user_id});
if ($li !== undefined) {
$li.remove(); $li.remove();
this.update_padding(); this.update_padding();
} }
} }
}
find_position(opts) { find_position(opts) {
const user_id = opts.user_id; const user_id = opts.user_id;
@ -623,9 +625,7 @@ export class BuddyList extends BuddyListConf {
const pos = this.all_user_ids.indexOf(user_id); const pos = this.all_user_ids.indexOf(user_id);
if (pos < 0) { if (pos < 0) {
// TODO: See ListCursor.get_row() for why this is return undefined;
// a bit janky now.
return [];
} }
this.force_render({ this.force_render({
@ -662,10 +662,12 @@ export class BuddyList extends BuddyListConf {
if (new_pos_in_all_users < this.render_count) { if (new_pos_in_all_users < this.render_count) {
this.render_count += 1; this.render_count += 1;
const $li = this.find_li({key: user_id_following_insertion}); const $li = this.find_li({key: user_id_following_insertion});
if ($li !== undefined) {
$li.before(html); $li.before(html);
this.update_padding(); this.update_padding();
} }
} }
}
insert_or_move(opts) { insert_or_move(opts) {
const user_id = opts.user_id; const user_id = opts.user_id;