From cbffc10e9e96b6e0cf8ef48142e098d337e2e137 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 30 May 2024 10:07:58 -0700 Subject: [PATCH] compose_fade: Fix TypeScript noUncheckedIndexedAccess errors. Signed-off-by: Anders Kaseorg --- web/src/compose_fade.ts | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/web/src/compose_fade.ts b/web/src/compose_fade.ts index d14d08da91..cf71a8069c 100644 --- a/web/src/compose_fade.ts +++ b/web/src/compose_fade.ts @@ -129,22 +129,16 @@ function fade_messages(): void { return; } - let i; - let first_message; - let $first_row; - let should_fade_group = false; - const visible_groups = message_viewport.visible_groups(false); - normal_display = false; // Update the visible messages first, before the compose box opens - for (i = 0; i < visible_groups.length; i += 1) { - $first_row = rows.first_message_in_group($(visible_groups[i])); - first_message = message_lists.current.get(rows.id($first_row)); + for (const group_elt of message_viewport.visible_groups(false)) { + const $first_row = rows.first_message_in_group($(group_elt)); + const first_message = message_lists.current.get(rows.id($first_row)); assert(first_message !== undefined); - should_fade_group = compose_fade_helper.should_fade_message(first_message); + const should_fade_group = compose_fade_helper.should_fade_message(first_message); - change_fade_state($(visible_groups[i]), should_fade_group); + change_fade_state($(group_elt), should_fade_group); } // Defer updating all message groups so that the compose box can open sooner @@ -158,13 +152,12 @@ function fade_messages(): void { return; } - should_fade_group = false; const $all_groups = message_lists.current.view.$list.find(".recipient_row"); // Note: The below algorithm relies on the fact that all_elts is // sorted as it would be displayed in the message view - for (i = 0; i < $all_groups.length; i += 1) { - const $group_elt = $($all_groups[i]); - should_fade_group = compose_fade_helper.should_fade_message( + for (const group_elt of $all_groups) { + const $group_elt = $(group_elt); + const should_fade_group = compose_fade_helper.should_fade_message( rows.recipient_from_group($group_elt)!, ); change_fade_state($group_elt, should_fade_group);