From 1d3da31b8b3d54074c5d1a2d5c2266edf90a05cd Mon Sep 17 00:00:00 2001 From: roanster007 Date: Fri, 7 Jun 2024 15:22:11 +0530 Subject: [PATCH] unread_ui: Refactor method to update unread banner. This commit refactors the "update_unread_banner", so that the "mark_read_on_scroll_state_banner" innerHtml is set using a separate method by passing the necessary template. This is a preparatory commit. --- web/src/unread_ui.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/web/src/unread_ui.ts b/web/src/unread_ui.ts index 3838d0c1ac..7903feef75 100644 --- a/web/src/unread_ui.ts +++ b/web/src/unread_ui.ts @@ -23,6 +23,10 @@ export function register_update_unread_counts_hook(f: UpdateUnreadCountsHook): v update_unread_counts_hooks.push(f); } +function set_mark_read_on_scroll_state_banner(template: string): void { + $("#mark_read_on_scroll_state_banner").html(template); +} + export function update_unread_banner(): void { if (message_lists.current === undefined) { return; @@ -34,17 +38,15 @@ export function update_unread_banner(): void { user_settings.web_mark_read_on_scroll_policy === web_mark_read_on_scroll_policy_values.never.code ) { - $("#mark_read_on_scroll_state_banner").html(render_mark_as_read_disabled_banner()); + set_mark_read_on_scroll_state_banner(render_mark_as_read_disabled_banner()); } else if ( user_settings.web_mark_read_on_scroll_policy === web_mark_read_on_scroll_policy_values.conversation_only.code && !is_conversation_view ) { - $("#mark_read_on_scroll_state_banner").html( - render_mark_as_read_only_in_conversation_view(), - ); + set_mark_read_on_scroll_state_banner(render_mark_as_read_only_in_conversation_view()); } else { - $("#mark_read_on_scroll_state_banner").html(render_mark_as_read_turned_off_banner()); + set_mark_read_on_scroll_state_banner(render_mark_as_read_turned_off_banner()); if (message_lists.current.can_mark_messages_read_without_setting()) { hide_unread_banner(); }