From 857c00f5ccf615b7cd916da066124142bfd37db4 Mon Sep 17 00:00:00 2001 From: bedo Date: Thu, 14 Nov 2024 18:43:25 +0200 Subject: [PATCH] move_topic_to_stream: Default "Move only this message" in search view. Fixes #32106 Default to "Move only this message" select option if the message is in search view, because the search view by its construction doesn't guarantee to show all/later messages in the relevant topic. --- web/src/stream_popover.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/web/src/stream_popover.js b/web/src/stream_popover.js index e7cda5742a..30105610c4 100644 --- a/web/src/stream_popover.js +++ b/web/src/stream_popover.js @@ -16,6 +16,7 @@ import {$t, $t_html} from "./i18n.ts"; import * as message_edit from "./message_edit.ts"; import * as message_lists from "./message_lists.ts"; import * as message_view from "./message_view.ts"; +import * as narrow_state from "./narrow_state.ts"; import * as popover_menus from "./popover_menus.ts"; import {left_sidebar_tippy_options} from "./popover_menus.ts"; import {web_channel_default_view_values} from "./settings_config.ts"; @@ -389,11 +390,20 @@ export async function build_move_topic_to_stream_popover( const move_limit_buffer = 5; args.disable_topic_input = !message_edit.is_topic_editable(message, move_limit_buffer); disable_stream_input = !message_edit.is_stream_editable(message, move_limit_buffer); - args.message_placement = await get_message_placement_in_conversation( - current_stream_id, - topic_name, - message.id, - ); + + // If message is in a search view, default to "move only this message" option, + // same as if it were the last message in any view. + if (narrow_state.is_search_view()) { + args.message_placement = "last"; + } + // Else, default option is based on the message placement in the view. + else { + args.message_placement = await get_message_placement_in_conversation( + current_stream_id, + topic_name, + message.id, + ); + } } function get_params_from_form() {