Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
eslint: Fix unicorn/prefer-hoisting-branch-code.
Anders Kaseorg5f423996f03d
diff --git a/web/src/inbox_ui.ts b/web/src/inbox_ui.tsindex 9c6a79ae523..8d86caeae89 100644--- a/web/src/inbox_ui.ts+++ b/web/src/inbox_ui.ts@@ -1432,33 +1432,27 @@ export function collapse_or_expand(container_id: string): void {let $all_elements = $(".inbox-header.inbox-folder, .inbox-folder-components");const $blocker = $("#inbox-animation-extra-content-blocker");$all_elements = $all_elements.add($blocker);- // If a folder was expanded/collapsed.+ let $content;if ($toggle_container.hasClass("inbox-folder")) {- const $content = $toggle_container.next(".inbox-folder-components");- animate.collapse_or_expand({- toggle_class: "inbox-collapsed-state",- $toggle_container,- $content,- $all_elements,- duration: animation_duration,- });- // If a channel was expanded/collapsed.+ // If a folder was expanded/collapsed.+ $content = $toggle_container.next(".inbox-folder-components");} else {- const $content = $toggle_container.next(".inbox-topic-container");+ // If a channel was expanded/collapsed.+ $content = $toggle_container.next(".inbox-topic-container");// Remove parent`.inbox-folder-components` and// add it's contents to `$all_elements`.const $parent_folder_components = $toggle_container.closest(".inbox-folder-components");$all_elements = $all_elements.not($parent_folder_components);const $parent_folder_components_children = $parent_folder_components.children().children();$all_elements = $all_elements.add($parent_folder_components_children);- animate.collapse_or_expand({- toggle_class: "inbox-collapsed-state",- $toggle_container,- $content,- $all_elements,- duration: animation_duration,- });}+ animate.collapse_or_expand({+ toggle_class: "inbox-collapsed-state",+ $toggle_container,+ $content,+ $all_elements,+ duration: animation_duration,+ });if (collapsed_containers.has(container_id)) {collapsed_containers.delete(container_id);diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.jsindex 023e437197d..3e7a7af2de5 100644--- a/web/src/server_events_dispatch.js+++ b/web/src/server_events_dispatch.js@@ -1169,11 +1169,10 @@ export function dispatch_normal_event(event) {if (event.op === "add") {starred_messages.add(event.messages);- starred_messages_ui.rerender_ui();} else {starred_messages.remove(event.messages);- starred_messages_ui.rerender_ui();}+ starred_messages_ui.rerender_ui();message_events.update_views_filtered_on_message_property(event.messages,"is-starred",diff --git a/web/src/settings_components.ts b/web/src/settings_components.tsindex f914ca503c4..11d9573f2a4 100644--- a/web/src/settings_components.ts+++ b/web/src/settings_components.ts@@ -1111,7 +1111,7 @@ export function populate_data_for_realm_settings_request(if (check_realm_settings_property_changed(input_elem)) {const input_value = get_input_element_value(input_elem);if (input_value !== undefined && input_value !== null) {- let property_name: string;+ let match_array;if ($input_elem.attr("id")!.startsWith("id_authmethod")) {// Authentication Method component IDs include authentication method name// for uniqueness, anchored to "id_authmethod" prefix, e.g. "id_authmethodapple_<property_name>".@@ -1119,16 +1119,12 @@ export function populate_data_for_realm_settings_request(// The [\da-z]+ part of the regexp covers the auth method name itself.// We assume it's not an empty string and can contain only digits and lowercase ASCII letters,// this is ensured by a respective allowlist-based filter in populate_auth_methods().- const match_array = /^id_authmethod[\da-z]+_(.*)$/.exec(- $input_elem.attr("id")!,- );- assert(match_array !== null);- property_name = match_array[1]!;+ match_array = /^id_authmethod[\da-z]+_(.*)$/.exec($input_elem.attr("id")!);} else {- const match_array = /^id_realm_(.*)$/.exec($input_elem.attr("id")!);- assert(match_array !== null);- property_name = match_array[1]!;+ match_array = /^id_realm_(.*)$/.exec($input_elem.attr("id")!);}+ assert(match_array !== null);+ const property_name = match_array[1]!;if (property_name === "org_join_restrictions") {assert(typeof input_value === "string");diff --git a/web/src/starred_messages_ui.ts b/web/src/starred_messages_ui.tsindex d0f78104b5c..093efd503d6 100644--- a/web/src/starred_messages_ui.ts+++ b/web/src/starred_messages_ui.ts@@ -36,12 +36,11 @@ export function toggle_starred_and_update_server(message: Message): void {if (message.starred) {message_flags.send_flag_update_for_messages([message.id], "starred", "add");starred_messages.add([message.id]);- rerender_ui();} else {message_flags.send_flag_update_for_messages([message.id], "starred", "remove");starred_messages.remove([message.id]);- rerender_ui();}+ rerender_ui();}// This updates the state of the starred flag in local datadiff --git a/web/src/stream_edit.ts b/web/src/stream_edit.tsindex 65b3b329179..54af7d2c09e 100644--- a/web/src/stream_edit.ts+++ b/web/src/stream_edit.ts@@ -187,29 +187,28 @@ export function save_stream_info(): void {assert(data.new_name !== undefined);const existing_stream = stream_data.get_sub_by_name(data.new_name);+ let rendered_error;if (existing_stream) {const can_rename =existing_stream.is_archived &&stream_settings_data.get_sub_for_settings(existing_stream).can_change_name_description;- const rendered_error = render_channel_name_conflict_error({+ rendered_error = render_channel_name_conflict_error({stream_id: existing_stream.stream_id,is_archived: existing_stream.is_archived,show_rename: can_rename,can_view_channel: true,});-- $("#change_stream_name_error").html(rendered_error).show();} else {- const rendered_error = render_channel_name_conflict_error({+ rendered_error = render_channel_name_conflict_error({stream_id: undefined,is_archived: false,show_rename: false,can_view_channel: false,});- $("#change_stream_name_error").html(rendered_error).show();}+ $("#change_stream_name_error").html(rendered_error).show();$("#change_stream_name").trigger("focus");}},