Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
eslint: Fix unicorn/prefer-else-if.
Anders Kaseorg14180472866d
diff --git a/web/src/admin.ts b/web/src/admin.tsindex 4d92c91f5d2..f1e6f70362a 100644--- a/web/src/admin.ts+++ b/web/src/admin.ts@@ -366,8 +366,7 @@ export function launch(section: string, settings_tab: string | undefined): void}if (section === "users") {settings_panel_menu.org_settings.set_user_settings_tab(settings_tab);- }- if (section === "bots") {+ } else if (section === "bots") {assert(settings_tab !== undefined);settings_panel_menu.org_settings.set_bot_settings_tab(settings_tab, "org");}diff --git a/web/src/channel_folders.ts b/web/src/channel_folders.tsindex df09f3cd6fd..502313c96d1 100644--- a/web/src/channel_folders.ts+++ b/web/src/channel_folders.ts@@ -113,9 +113,7 @@ export function update_channel_folder(if (property === "name") {channel_folder_name_dict.delete(old_value);channel_folder_name_dict.set(channel_folder.name, channel_folder);- }-- if (property === "rendered_description") {+ } else if (property === "rendered_description") {clean_up_description(channel_folder);}}diff --git a/web/src/filter.ts b/web/src/filter.tsindex 35def640eca..ac9f8ee8795 100644--- a/web/src/filter.ts+++ b/web/src/filter.ts@@ -946,34 +946,39 @@ export class Filter {}const prefix_for_operator = this.operator_to_prefix(term.operator, term.negated);if (prefix_for_operator !== "") {- if (term.operator === "channel") {- const stream = stream_data.get_sub_by_id_string(term.operand);- const verb = term.negated ? "exclude " : "";- if (stream) {+ switch (term.operator) {+ case "channel": {+ const stream = stream_data.get_sub_by_id_string(term.operand);+ const verb = term.negated ? "exclude " : "";+ if (stream) {+ return {+ type: "channel",+ prefix_for_operator: verb + "messages in ",+ stream,+ };+ }+ // Assume the operand is a partially formed name and return+ // the operator as the channel name in the next block.+ /* istanbul ignore next */+ break;+ }+ case "date":return {- type: "channel",- prefix_for_operator: verb + "messages in ",- stream,+ type: "prefix_for_operator",+ prefix_for_operator:+ term.operand === "" ? prefix_for_operator : "messages sent around",+ operand: date_util.convert_date_str_to_description_date(term.operand),};- }- // Assume the operand is a partially formed name and return- // the operator as the channel name in the next block.- }- if (term.operator === "date") {- return {- type: "prefix_for_operator",- prefix_for_operator:- term.operand === "" ? prefix_for_operator : "messages sent around",- operand: date_util.convert_date_str_to_description_date(term.operand),- };- }- if (term.operator === "topic" && !is_operator_suggestion) {- return {- type: "prefix_for_operator",- prefix_for_operator,- operand: util.get_final_topic_display_name(term.operand),- is_empty_string_topic: term.operand === "",- };+ case "topic":+ if (!is_operator_suggestion) {+ return {+ type: "prefix_for_operator",+ prefix_for_operator,+ operand: util.get_final_topic_display_name(term.operand),+ is_empty_string_topic: term.operand === "",+ };+ }+ break;}return {type: "prefix_for_operator",diff --git a/web/src/flatpickr.ts b/web/src/flatpickr.tsindex 42a062087b1..87c9931fee4 100644--- a/web/src/flatpickr.ts+++ b/web/src/flatpickr.ts@@ -143,35 +143,34 @@ export function show_flatpickr(return true;}- if (e.key === "Backspace" || e.key === "Delete") {- // Let backspace or delete be handled normally- return true;- }-- if (e.key === "Enter") {- if (e.target.classList[0] === "flatpickr-day") {- // use flatpickr's built-in behavior to choose the selected day.+ switch (e.key) {+ case "Backspace":+ case "Delete":+ // Let backspace or delete be handled normally+ return true;+ case "Enter":+ if (e.target.classList[0] === "flatpickr-day") {+ // use flatpickr's built-in behavior to choose the selected day.+ return true;+ }+ if (!hide_confirm_button) {+ $container.find(".flatpickr-confirm").trigger("click");+ }+ break;+ case "Escape":+ flatpickr_instance?.close();+ flatpickr_instance?.destroy();+ break;+ case "Tab":+ // Use flatpickr's built-in navigation between elements.+ return true;+ case "ArrowLeft":+ case "ArrowUp":+ case "ArrowRight":+ case "ArrowDown":+ // use flatpickr's built-in navigation of the date grid.+ e.stopPropagation();return true;- }- if (!hide_confirm_button) {- $container.find(".flatpickr-confirm").trigger("click");- }- }-- if (e.key === "Escape") {- flatpickr_instance?.close();- flatpickr_instance?.destroy();- }-- if (e.key === "Tab") {- // Use flatpickr's built-in navigation between elements.- return true;- }-- if (["ArrowLeft", "ArrowUp", "ArrowRight", "ArrowDown"].includes(e.key)) {- // use flatpickr's built-in navigation of the date grid.- e.stopPropagation();- return true;}e.stopPropagation();diff --git a/web/src/hash_util.ts b/web/src/hash_util.tsindex 224665dfb33..5c96c0d3a3f 100644--- a/web/src/hash_util.ts+++ b/web/src/hash_util.ts@@ -73,16 +73,12 @@ export function decode_operand(case "dm":return [people.my_current_user_id()];}- }-- if (operator === "dm-including" || operator === "dm") {+ } else if (operator === "dm-including" || operator === "dm") {const user_ids = people.slug_to_user_ids(operand);if (user_ids) {return user_ids;}- }-- if (operator === "sender" || operator === "mentions") {+ } else if (operator === "sender" || operator === "mentions") {const user_ids = people.slug_to_user_ids(operand);if (user_ids?.length !== 1) {// User mistyped the URL since we don't supportdiff --git a/web/src/hashchange.ts b/web/src/hashchange.tsindex 6539c817635..f346ca5c369 100644--- a/web/src/hashchange.ts+++ b/web/src/hashchange.ts@@ -302,45 +302,48 @@ function do_hashchange_overlay(old_hash: string | undefined): void {}const coming_from_overlay = hash_parser.is_overlay_hash(old_hash);- if (base === "settings" || base === "organization") {- let settings_panel_object = settings_panel_menu.normal_settings;- if (base === "organization") {- settings_panel_object = settings_panel_menu.org_settings;- }- const valid_hash = hash_util.validate_settings_hash(- window.location.hash,- settings_panel_object,- );-- if (valid_hash !== window.location.hash) {- window.history.replaceState(null, "", browser_history.get_full_url(valid_hash));- section = hash_parser.get_hash_section(valid_hash);+ switch (base) {+ case "settings":+ case "organization": {+ let settings_panel_object = settings_panel_menu.normal_settings;+ if (base === "organization") {+ settings_panel_object = settings_panel_menu.org_settings;+ }+ const valid_hash = hash_util.validate_settings_hash(+ window.location.hash,+ settings_panel_object,+ );++ if (valid_hash !== window.location.hash) {+ window.history.replaceState(null, "", browser_history.get_full_url(valid_hash));+ section = hash_parser.get_hash_section(valid_hash);+ }++ break;}- }+ case "streams":+ case "channels": {+ const valid_hash = hash_util.validate_channels_settings_hash(window.location.hash);+ // Here valid_hash will always return "channels" as the base.+ // So, if we update the history because the valid hash does+ // not match the window.location.hash, then we also reset the+ // base string we're tracking for the hash.+ if (valid_hash !== window.location.hash) {+ window.history.replaceState(null, "", browser_history.get_full_url(valid_hash));+ section = hash_parser.get_current_hash_section();+ base = hash_parser.get_current_hash_category();+ }- // In 2024, stream was renamed to channel in the Zulip API and UI.- // Because pre-change Welcome Bot and Notification Bot messages- // included links to "/#streams/all" and "/#streams/new", we'll- // need to support "streams" as an overlay hash as an alias for- // "channels" permanently.- if (base === "streams" || base === "channels") {- const valid_hash = hash_util.validate_channels_settings_hash(window.location.hash);- // Here valid_hash will always return "channels" as the base.- // So, if we update the history because the valid hash does- // not match the window.location.hash, then we also reset the- // base string we're tracking for the hash.- if (valid_hash !== window.location.hash) {- window.history.replaceState(null, "", browser_history.get_full_url(valid_hash));- section = hash_parser.get_current_hash_section();- base = hash_parser.get_current_hash_category();+ break;}- }+ case "groups": {+ const valid_hash = hash_util.validate_group_settings_hash(window.location.hash);+ if (valid_hash !== window.location.hash) {+ window.history.replaceState(null, "", browser_history.get_full_url(valid_hash));+ section = hash_parser.get_current_hash_section();+ }- if (base === "groups") {- const valid_hash = hash_util.validate_group_settings_hash(window.location.hash);- if (valid_hash !== window.location.hash) {- window.history.replaceState(null, "", browser_history.get_full_url(valid_hash));- section = hash_parser.get_current_hash_section();+ break;}}@@ -350,55 +353,55 @@ function do_hashchange_overlay(old_hash: string | undefined): void {// In most situations we skip by this logic and load// the new overlay.if (coming_from_overlay && base === old_base) {- if (base === "channels") {- if (hash_parser.get_current_nth_hash_section(1) === "folders") {- const folder_id = hash_parser.get_current_nth_hash_section(2);- // Folder-create: show create form; left tab unchanged.- stream_settings_ui.change_state(- "new",- undefined,- undefined,- Number.parseInt(folder_id, 10),- );+ switch (base) {+ case "channels": {+ if (hash_parser.get_current_nth_hash_section(1) === "folders") {+ const folder_id = hash_parser.get_current_nth_hash_section(2);+ // Folder-create: show create form; left tab unchanged.+ stream_settings_ui.change_state(+ "new",+ undefined,+ undefined,+ Number.parseInt(folder_id, 10),+ );+ return;+ }++ // e.g. #channels/29/social/subscribers+ const {right_panel, left_side_tab} = channels_overlay_state_from_hash();+ const right_side_tab = hash_parser.get_current_nth_hash_section(3);+ stream_settings_ui.change_state(right_panel, left_side_tab, right_side_tab);return;}-- // e.g. #channels/29/social/subscribers- const {right_panel, left_side_tab} = channels_overlay_state_from_hash();- const right_side_tab = hash_parser.get_current_nth_hash_section(3);- stream_settings_ui.change_state(right_panel, left_side_tab, right_side_tab);- return;- }-- if (base === "groups") {- const right_side_tab = hash_parser.get_current_nth_hash_section(3);- user_group_edit.change_state(section, undefined, right_side_tab);- }-- if (base === "settings") {- if (!section) {- // We may be on a really old browser or somebody- // hand-typed a hash.- blueslip.warn("missing section for settings");+ case "groups": {+ const right_side_tab = hash_parser.get_current_nth_hash_section(3);+ user_group_edit.change_state(section, undefined, right_side_tab);+ break;}- settings_panel_menu.normal_settings.activate_section_or_default(- section,- get_settings_tab(section),- );- return;- }-- if (base === "organization") {- if (!section) {- // We may be on a really old browser or somebody- // hand-typed a hash.- blueslip.warn("missing section for organization");+ case "settings": {+ if (!section) {+ // We may be on a really old browser or somebody+ // hand-typed a hash.+ blueslip.warn("missing section for settings");+ }+ settings_panel_menu.normal_settings.activate_section_or_default(+ section,+ get_settings_tab(section),+ );+ return;+ }+ case "organization": {+ if (!section) {+ // We may be on a really old browser or somebody+ // hand-typed a hash.+ blueslip.warn("missing section for organization");+ }+ settings_panel_menu.org_settings.activate_section_or_default(+ section,+ get_settings_tab(section),+ );+ return;}- settings_panel_menu.org_settings.activate_section_or_default(- section,- get_settings_tab(section),- );- return;}// TODO: handle other cases like internal settingsdiff --git a/web/src/information_density.ts b/web/src/information_density.tsindex bf6bd69ac1c..51c17847fa4 100644--- a/web/src/information_density.ts+++ b/web/src/information_density.ts@@ -380,9 +380,7 @@ export function get_tooltip_context_for_info_density_buttons(}}}- }-- if (property === "web_line_height_percent") {+ } else if (property === "web_line_height_percent") {if (is_default_button) {if (is_current_value_default) {tooltip_first_line = $t({defaultMessage: "Already at default line spacing"});diff --git a/web/src/messages_overlay_ui.ts b/web/src/messages_overlay_ui.tsindex 2b0269ae099..c4f2b2fdc74 100644--- a/web/src/messages_overlay_ui.ts+++ b/web/src/messages_overlay_ui.ts@@ -95,9 +95,7 @@ export function modals_handle_events(event_key: string, context: Context): voidif (event_key === "backspace" || event_key === "delete") {context.on_delete();- }-- if (event_key === "enter") {+ } else if (event_key === "enter") {context.on_enter();}}diff --git a/web/src/pill_typeahead.ts b/web/src/pill_typeahead.tsindex 86ce6ef1329..637d5e5ffb2 100644--- a/web/src/pill_typeahead.ts+++ b/web/src/pill_typeahead.ts@@ -213,9 +213,7 @@ export function set_up_group_setting_typeahead(let matches = false;if (item.type === "user_group") {matches ||= group_matcher(query, item, should_remove_diacritics);- }-- if (item.type === "user") {+ } else if (item.type === "user") {matches ||= person_matcher(query, item, should_remove_diacritics);}return matches;diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.jsindex 3e7a7af2de5..ebd5630e73b 100644--- a/web/src/server_events_dispatch.js+++ b/web/src/server_events_dispatch.js@@ -401,11 +401,6 @@ export function dispatch_normal_event(event) {realm["realm_" + key] = value;}- if (key === "topics_policy") {- compose_recipient.update_topic_inputbox_on_topics_policy_change();- compose_recipient.update_compose_area_placeholder_text();- }-if (Object.hasOwn(realm_settings, key)) {settings_org.sync_realm_settings(key);realm_settings[key]();@@ -422,51 +417,50 @@ export function dispatch_normal_event(event) {);}- if (- key === "create_multiuse_invite_group" ||- key === "can_invite_users_group"- ) {- settings_invites.update_invite_user_panel();- sidebar_ui.update_invite_user_option();- gear_menu.rerender();- }-- if (- key === "direct_message_initiator_group" ||- key === "direct_message_permission_group"- ) {- settings_org.check_disable_direct_message_initiator_group_widget();- compose_closed_ui.maybe_update_buttons_for_dm_recipient();- compose_validate.validate_and_update_send_button_status();- }-- if (- key === "can_move_messages_between_topics_group" ||- key === "can_resolve_topics_group"- ) {- // Technically we just need to rerender the message recipient- // bars to update the buttons for editing or resolving a topic,- // but because these policies are changed rarely, it's fine to- // rerender the entire message feed.- message_live_update.rerender_messages_view();- }-- if (key === "plan_type") {- gear_menu.rerender();- }-- if (- key === "can_add_subscribers_group" &&- overlays.streams_open()- ) {- const active_stream_id =- stream_settings_components.get_active_data().id;- if (active_stream_id !== undefined) {- const slim_sub = sub_store.get(active_stream_id);- const sub =- stream_settings_data.get_sub_for_settings(slim_sub);- stream_ui_updates.update_add_subscriptions_elements(sub);- }+ switch (key) {+ case "topics_policy":+ compose_recipient.update_topic_inputbox_on_topics_policy_change();+ compose_recipient.update_compose_area_placeholder_text();+ break;+ case "create_multiuse_invite_group":+ case "can_invite_users_group":+ settings_invites.update_invite_user_panel();+ sidebar_ui.update_invite_user_option();+ gear_menu.rerender();+ break;+ case "direct_message_initiator_group":+ case "direct_message_permission_group":+ settings_org.check_disable_direct_message_initiator_group_widget();+ compose_closed_ui.maybe_update_buttons_for_dm_recipient();+ compose_validate.validate_and_update_send_button_status();+ break;+ case "can_move_messages_between_topics_group":+ case "can_resolve_topics_group":+ // Technically we just need to rerender the message recipient+ // bars to update the buttons for editing or resolving a topic,+ // but because these policies are changed rarely, it's fine to+ // rerender the entire message feed.+ message_live_update.rerender_messages_view();+ break;+ case "plan_type":+ gear_menu.rerender();+ break;+ case "can_add_subscribers_group":+ if (overlays.streams_open()) {+ const active_stream_id =+ stream_settings_components.get_active_data().id;+ if (active_stream_id !== undefined) {+ const slim_sub = sub_store.get(active_stream_id);+ const sub =+ stream_settings_data.get_sub_for_settings(+ slim_sub,+ );+ stream_ui_updates.update_add_subscriptions_elements(+ sub,+ );+ }+ }+ break;}}if (event.data.authentication_methods !== undefined) {@@ -973,8 +967,7 @@ export function dispatch_normal_event(event) {settings_account.update_privacy_settings_box(event.property);if (event.property === "presence_enabled") {activity_ui.redraw_user(current_user.user_id);- }- if (event.property === "allow_private_data_export") {+ } else if (event.property === "allow_private_data_export") {settings_exports.refresh_allow_private_data_export_banner();}break;@@ -1014,145 +1007,142 @@ export function dispatch_normal_event(event) {if (user_preferences.includes(event.property)) {user_settings[event.property] = event.value;}- if (event.property === "default_language") {- // We additionally need to set the language name.- //- // Note that this does not change translations at all;- // a reload is fundamentally required because we- // cannot rerender with the new language the strings- // present in the backend/Jinja2 templates.- settings_preferences.set_default_language(event.value);- }- if (event.property === "web_home_view") {- left_sidebar_navigation_area.handle_home_view_changed(event.value);-- // If current hash is empty (home view), and the- // user changes the home view while in settings,- // then going back to an empty hash on closing the- // overlay will not match the view currently displayed- // under settings, so we set the hash to the previous- // value of the home view.- if (!browser_history.state.hash_before_overlay && overlays.settings_open()) {- browser_history.state.hash_before_overlay = "#" + original_home_view;- }- }- if (event.property === "twenty_four_hour_time") {- // Recalculate timestamp column width- information_density.calculate_timestamp_widths();- // Rerender the whole message list UI- for (const msg_list of message_lists.all_rendered_message_lists()) {- msg_list.rerender();- }- }- if (event.property === "high_contrast_mode") {- $("body").toggleClass("high-contrast", event.value);- }- if (event.property === "demote_inactive_streams") {- stream_list_sort.set_filter_out_inactives();- stream_list.update_streams_sidebar(true);- }- if (event.property === "web_animate_image_previews") {- // Rerender the whole message list UI- for (const msg_list of message_lists.all_rendered_message_lists()) {- msg_list.rerender();- }- }- if (event.property === "web_stream_unreads_count_display_policy") {- stream_list.build_stream_list(true);- }- if (event.property === "user_list_style") {- settings_preferences.report_user_list_style_change(- settings_preferences.user_settings_panel,- );- activity_ui.build_user_sidebar();- }- if (- event.property === "web_font_size_px" ||- event.property === "web_line_height_percent"- ) {- // We just ignore events for web_font_size_px"- // and "web_line_height_percent" settings as we- // are fine with a window not being updated due- // to changes being done from another window and- // also helps in avoiding weird issues on clicking- // the "+"/"-" buttons multiple times quickly when- // updating these settings.- }-- if (event.property === "web_mark_read_on_scroll_policy") {- unread_ui.update_unread_banner();- }- if (event.property === "color_scheme") {- requestAnimationFrame(() => {- theme.set_theme_and_update(event.value);- });- }- if (event.property === "starred_message_counts") {- starred_messages_ui.rerender_ui();- }- if (event.property === "web_left_sidebar_unreads_count_summary") {- stream_list.update_unread_counts_visibility();- }- if (event.property === "web_left_sidebar_show_channel_folders") {- stream_list.update_collapsed_state_on_show_channel_folders_change();- stream_list.build_stream_list(true);- }- if (event.property === "web_inbox_show_channel_folders") {- inbox_ui.complete_rerender();- }- if (- event.property === "receives_typing_notifications" &&- !user_settings.receives_typing_notifications- ) {- typing_events.disable_typing_notification();- }- if (event.property === "fluid_layout_width") {- scroll_bar.set_layout_width();- }- if (event.property === "default_language") {- // TODO: Make this change the view immediately rather than- // requiring a reload. This is likely fairly difficult,- // because various i18n strings are rendered by the- // server; we may want to instead just trigger a page- // reload.- }- if (event.property === "emojiset") {- settings_preferences.report_emojiset_change(- settings_preferences.user_settings_panel,- );- // Rerender the whole message list UI- for (const msg_list of message_lists.all_rendered_message_lists()) {- msg_list.rerender();- }- // Rerender buddy list status emoji- activity_ui.build_user_sidebar();- }-- if (event.property === "display_emoji_reaction_users") {- message_live_update.rerender_messages_view();- }- if (event.property === "web_escape_navigates_to_home_view") {- $("#keyboard-shortcuts .go-to-home-view-hotkey-help").toggleClass(- "notdisplayed",- !event.value,- );- }- if (event.property === "web_suggest_update_timezone") {- $("#automatically_offer_update_time_zone").prop("checked", event.value);- }- if (event.property === "web_channel_default_view") {- // We need to rerender wherever `channel_url_by_user_setting` is used in the DOM.- // Left sidebar- const force_rerender = true;- stream_list.create_initial_sidebar_rows(force_rerender);- stream_list.update_streams_sidebar(force_rerender);- // Inbox View- inbox_ui.complete_rerender();- // Recent View- recent_view_ui.complete_rerender();- // Message feed- for (const msg_list of message_lists.all_rendered_message_lists()) {- msg_list.rerender();+ switch (event.property) {+ case "default_language":+ // We additionally need to set the language name.+ //+ // Note that this does not change translations at all;+ // a reload is fundamentally required because we+ // cannot rerender with the new language the strings+ // present in the backend/Jinja2 templates.+ settings_preferences.set_default_language(event.value);++ // TODO: Make this change the view immediately rather than+ // requiring a reload. This is likely fairly difficult,+ // because various i18n strings are rendered by the+ // server; we may want to instead just trigger a page+ // reload.+ break;+ case "web_home_view":+ left_sidebar_navigation_area.handle_home_view_changed(event.value);++ // If current hash is empty (home view), and the+ // user changes the home view while in settings,+ // then going back to an empty hash on closing the+ // overlay will not match the view currently displayed+ // under settings, so we set the hash to the previous+ // value of the home view.+ if (!browser_history.state.hash_before_overlay && overlays.settings_open()) {+ browser_history.state.hash_before_overlay = "#" + original_home_view;+ }+ break;+ case "twenty_four_hour_time":+ // Recalculate timestamp column width+ information_density.calculate_timestamp_widths();+ // Rerender the whole message list UI+ for (const msg_list of message_lists.all_rendered_message_lists()) {+ msg_list.rerender();+ }+ break;+ case "high_contrast_mode":+ $("body").toggleClass("high-contrast", event.value);+ break;+ case "demote_inactive_streams":+ stream_list_sort.set_filter_out_inactives();+ stream_list.update_streams_sidebar(true);+ break;+ case "web_animate_image_previews":+ // Rerender the whole message list UI+ for (const msg_list of message_lists.all_rendered_message_lists()) {+ msg_list.rerender();+ }+ break;+ case "web_stream_unreads_count_display_policy":+ stream_list.build_stream_list(true);+ break;+ case "user_list_style":+ settings_preferences.report_user_list_style_change(+ settings_preferences.user_settings_panel,+ );+ activity_ui.build_user_sidebar();+ break;+ case "web_font_size_px":+ case "web_line_height_percent":+ // We just ignore events for web_font_size_px"+ // and "web_line_height_percent" settings as we+ // are fine with a window not being updated due+ // to changes being done from another window and+ // also helps in avoiding weird issues on clicking+ // the "+"/"-" buttons multiple times quickly when+ // updating these settings.+ break;+ case "web_mark_read_on_scroll_policy":+ unread_ui.update_unread_banner();+ break;+ case "color_scheme":+ requestAnimationFrame(() => {+ theme.set_theme_and_update(event.value);+ });+ break;+ case "starred_message_counts":+ starred_messages_ui.rerender_ui();+ break;+ case "web_left_sidebar_unreads_count_summary":+ stream_list.update_unread_counts_visibility();+ break;+ case "web_left_sidebar_show_channel_folders":+ stream_list.update_collapsed_state_on_show_channel_folders_change();+ stream_list.build_stream_list(true);+ break;+ case "web_inbox_show_channel_folders":+ inbox_ui.complete_rerender();+ break;+ case "receives_typing_notifications":+ if (!user_settings.receives_typing_notifications) {+ typing_events.disable_typing_notification();+ }+ break;+ case "fluid_layout_width":+ scroll_bar.set_layout_width();+ break;+ case "emojiset":+ settings_preferences.report_emojiset_change(+ settings_preferences.user_settings_panel,+ );+ // Rerender the whole message list UI+ for (const msg_list of message_lists.all_rendered_message_lists()) {+ msg_list.rerender();+ }+ // Rerender buddy list status emoji+ activity_ui.build_user_sidebar();+ break;+ case "display_emoji_reaction_users":+ message_live_update.rerender_messages_view();+ break;+ case "web_escape_navigates_to_home_view":+ $("#keyboard-shortcuts .go-to-home-view-hotkey-help").toggleClass(+ "notdisplayed",+ !event.value,+ );+ break;+ case "web_suggest_update_timezone":+ $("#automatically_offer_update_time_zone").prop("checked", event.value);+ break;+ case "web_channel_default_view": {+ // We need to rerender wherever `channel_url_by_user_setting` is used in the DOM.+ // Left sidebar+ const force_rerender = true;+ stream_list.create_initial_sidebar_rows(force_rerender);+ stream_list.update_streams_sidebar(force_rerender);+ // Inbox View+ inbox_ui.complete_rerender();+ // Recent View+ recent_view_ui.complete_rerender();+ // Message feed+ for (const msg_list of message_lists.all_rendered_message_lists()) {+ msg_list.rerender();+ }+ break;}}settings_preferences.update_page(event.property);diff --git a/web/src/stream_events.ts b/web/src/stream_events.tsindex 063bad8a739..c377554a91c 100644--- a/web/src/stream_events.ts+++ b/web/src/stream_events.ts@@ -109,25 +109,29 @@ export function update_property<P extends keyof UpdatableStreamProperties>(sub,group_setting_value_schema.parse(value),);- if (property === "can_subscribe_group" || property === "can_add_subscribers_group") {- stream_settings_ui.update_subscription_elements(sub);- }- if (property === "can_administer_channel_group") {- const settings_sub = stream_settings_data.get_sub_for_settings(sub);- stream_ui_updates.update_add_subscriptions_elements(settings_sub);- }- if (property === "can_resolve_topics_group") {- // Technically we just need to rerender the message recipient- // bars to update the buttons for editing or resolving a topic,- // but because these policies are changed rarely, it's fine to- // rerender the entire message feed.- message_live_update.rerender_messages_view();- }- if (property === "can_create_topic_group") {- stream_ui_updates.update_history_public_to_subscribers_state(- $("#stream_settings"),- sub,- );+ switch (property) {+ case "can_subscribe_group":+ case "can_add_subscribers_group":+ stream_settings_ui.update_subscription_elements(sub);+ break;+ case "can_administer_channel_group": {+ const settings_sub = stream_settings_data.get_sub_for_settings(sub);+ stream_ui_updates.update_add_subscriptions_elements(settings_sub);+ break;+ }+ case "can_resolve_topics_group":+ // Technically we just need to rerender the message recipient+ // bars to update the buttons for editing or resolving a topic,+ // but because these policies are changed rarely, it's fine to+ // rerender the entire message feed.+ message_live_update.rerender_messages_view();+ break;+ case "can_create_topic_group":+ stream_ui_updates.update_history_public_to_subscribers_state(+ $("#stream_settings"),+ sub,+ );+ break;}user_group_edit.update_stream_setting_in_permissions_panel(stream_permission_group_settings_schema.parse(property),diff --git a/web/src/unread.ts b/web/src/unread.tsindex 350d55f50c3..98b9740c464 100644--- a/web/src/unread.ts+++ b/web/src/unread.ts@@ -842,9 +842,7 @@ export function process_unread_message(message: UnreadMessageData): void {message_id: message.id,user_ids_string: message.user_ids_string,});- }-- if (message.type === "stream") {+ } else if (message.type === "stream") {unread_topic_counter.add({message_id: message.id,stream_id: message.stream_id,diff --git a/web/tests/components.test.cjs b/web/tests/components.test.cjsindex 59d6fa91a8b..cc4c0f2f1a9 100644--- a/web/tests/components.test.cjs+++ b/web/tests/components.test.cjs@@ -63,8 +63,7 @@ function make_tab(i) {$self.trigger = (type) => {if (type === "focus") {env.focused_tab = i;- }- if (type === "click") {+ } else if (type === "click") {env.click_f.call(env.tabs[i]);}};