mirror of
https://github.com/zulip/zulip.git
synced 2025-11-17 12:21:58 +00:00
compose: Don't jump to sent message conversation if setting disabled.
In a2ef1d7e93, we made changes so
that when you send a message, your view jumps to the conversation
where you sent it.
For some users it was an improvement, few reported that it
disrupts their workflows.
This commit updates the logic to NOT jump to the conversation
where you sent message if the setting
'Automatically go to conversation where you sent a message' is
disabled in 'SETTINGS / PREFERENCES > Advanced'.
We restore the old behaviour for the setting disabled case.
Fixes #30600.
This commit is contained in:
committed by
Tim Abbott
parent
83414db72e
commit
ab13b7f6fa
@@ -24,6 +24,7 @@ const MESSAGE_SENT_CLASSNAMES = {
|
|||||||
message_scheduled_success_compose_banner: "message_scheduled_success_compose_banner",
|
message_scheduled_success_compose_banner: "message_scheduled_success_compose_banner",
|
||||||
automatic_new_visibility_policy: "automatic_new_visibility_policy",
|
automatic_new_visibility_policy: "automatic_new_visibility_policy",
|
||||||
jump_to_sent_message_conversation: "jump_to_sent_message_conversation",
|
jump_to_sent_message_conversation: "jump_to_sent_message_conversation",
|
||||||
|
narrow_to_recipient: "narrow_to_recipient",
|
||||||
};
|
};
|
||||||
// Technically, unmute_topic_notification is a message sent banner, but
|
// Technically, unmute_topic_notification is a message sent banner, but
|
||||||
// it has distinct behavior / look - it has an associated action button,
|
// it has distinct behavior / look - it has an associated action button,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import * as narrow_state from "./narrow_state";
|
|||||||
import * as onboarding_steps from "./onboarding_steps";
|
import * as onboarding_steps from "./onboarding_steps";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
|
import {user_settings} from "./user_settings";
|
||||||
import * as user_topics from "./user_topics";
|
import * as user_topics from "./user_topics";
|
||||||
|
|
||||||
export function notify_unmute(muted_narrow: string, stream_id: number, topic_name: string): void {
|
export function notify_unmute(muted_narrow: string, stream_id: number, topic_name: string): void {
|
||||||
@@ -118,9 +119,13 @@ export function get_muted_narrow(message: Message): string | undefined {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function is_local_mix(message: Message): boolean {
|
export function should_jump_to_sent_message_conversation(message: Message): boolean {
|
||||||
|
if (!user_settings.web_navigate_to_sent_message) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (message_lists.current === undefined) {
|
if (message_lists.current === undefined) {
|
||||||
// For non-message list views like Inbox, the message is not visible after sending it.
|
// Non-message list views like Inbox.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,6 +145,37 @@ export function is_local_mix(message: Message): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function should_show_narrow_to_recipient_banner(message: Message): boolean {
|
||||||
|
if (user_settings.web_navigate_to_sent_message) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message_lists.current === undefined) {
|
||||||
|
// Non-message list views like Inbox.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const $row = message_lists.current.get_row(message.id);
|
||||||
|
if ($row.length > 0) {
|
||||||
|
// Our message is in the current message list.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// offscreen because it is outside narrow
|
||||||
|
// we can only look for these on non-search (can_apply_locally) messages
|
||||||
|
// see also: notify_messages_outside_current_search
|
||||||
|
const current_filter = narrow_state.filter();
|
||||||
|
if (
|
||||||
|
current_filter &&
|
||||||
|
current_filter.can_apply_locally() &&
|
||||||
|
!current_filter.predicate()(message)
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
export function notify_local_mixes(
|
export function notify_local_mixes(
|
||||||
messages: Message[],
|
messages: Message[],
|
||||||
need_user_to_scroll: boolean,
|
need_user_to_scroll: boolean,
|
||||||
@@ -173,11 +209,12 @@ export function notify_local_mixes(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const local_mix = is_local_mix(message);
|
const jump_to_sent_message_conversation = should_jump_to_sent_message_conversation(message);
|
||||||
|
const show_narrow_to_recipient_banner = should_show_narrow_to_recipient_banner(message);
|
||||||
|
|
||||||
const link_msg_id = message.id;
|
const link_msg_id = message.id;
|
||||||
|
|
||||||
if (!local_mix) {
|
if (!jump_to_sent_message_conversation && !show_narrow_to_recipient_banner) {
|
||||||
if (need_user_to_scroll) {
|
if (need_user_to_scroll) {
|
||||||
const banner_text = $t({defaultMessage: "Sent!"});
|
const banner_text = $t({defaultMessage: "Sent!"});
|
||||||
const link_text = $t({defaultMessage: "Scroll down to view your message."});
|
const link_text = $t({defaultMessage: "Scroll down to view your message."});
|
||||||
@@ -197,6 +234,24 @@ export function notify_local_mixes(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (show_narrow_to_recipient_banner) {
|
||||||
|
const banner_text = $t({
|
||||||
|
defaultMessage: "Sent! Your message is outside your current view.",
|
||||||
|
});
|
||||||
|
const link_text = $t(
|
||||||
|
{defaultMessage: "Go to {message_recipient}"},
|
||||||
|
{message_recipient: get_message_header(message)},
|
||||||
|
);
|
||||||
|
notify_above_composebox(
|
||||||
|
banner_text,
|
||||||
|
compose_banner.CLASSNAMES.narrow_to_recipient,
|
||||||
|
get_above_composebox_narrow_url(message),
|
||||||
|
link_msg_id,
|
||||||
|
link_text,
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
narrow_to_recipient(link_msg_id);
|
narrow_to_recipient(link_msg_id);
|
||||||
|
|
||||||
if (onboarding_steps.ONE_TIME_NOTICES_TO_DISPLAY.has("jump_to_conversation_banner")) {
|
if (onboarding_steps.ONE_TIME_NOTICES_TO_DISPLAY.has("jump_to_conversation_banner")) {
|
||||||
@@ -227,6 +282,28 @@ function get_above_composebox_narrow_url(message: Message): string {
|
|||||||
return above_composebox_narrow_url;
|
return above_composebox_narrow_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for callback when we have to check with the server if a message should be in
|
||||||
|
// the message_lists.current (!can_apply_locally; a.k.a. "a search").
|
||||||
|
export function notify_messages_outside_current_search(messages: Message[]): void {
|
||||||
|
for (const message of messages) {
|
||||||
|
if (!people.is_current_user(message.sender_email)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const above_composebox_narrow_url = get_above_composebox_narrow_url(message);
|
||||||
|
const link_text = $t(
|
||||||
|
{defaultMessage: "Narrow to {message_recipient}"},
|
||||||
|
{message_recipient: get_message_header(message)},
|
||||||
|
);
|
||||||
|
notify_above_composebox(
|
||||||
|
$t({defaultMessage: "Sent! Your recent message is outside the current search."}),
|
||||||
|
compose_banner.CLASSNAMES.narrow_to_recipient,
|
||||||
|
above_composebox_narrow_url,
|
||||||
|
message.id,
|
||||||
|
link_text,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function reify_message_id(opts: {old_id: number; new_id: number}): void {
|
export function reify_message_id(opts: {old_id: number; new_id: number}): void {
|
||||||
const old_id = opts.old_id;
|
const old_id = opts.old_id;
|
||||||
const new_id = opts.new_id;
|
const new_id = opts.new_id;
|
||||||
|
|||||||
@@ -56,10 +56,14 @@ function maybe_add_narrowed_messages(messages, msg_list, callback, attempt = 1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
let new_messages = [];
|
let new_messages = [];
|
||||||
|
const elsewhere_messages = [];
|
||||||
|
|
||||||
for (const elem of messages) {
|
for (const elem of messages) {
|
||||||
if (Object.hasOwn(data.messages, elem.id)) {
|
if (Object.hasOwn(data.messages, elem.id)) {
|
||||||
util.set_match_data(elem, data.messages[elem.id]);
|
util.set_match_data(elem, data.messages[elem.id]);
|
||||||
new_messages.push(elem);
|
new_messages.push(elem);
|
||||||
|
} else {
|
||||||
|
elsewhere_messages.push(elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +81,7 @@ function maybe_add_narrowed_messages(messages, msg_list, callback, attempt = 1)
|
|||||||
|
|
||||||
callback(new_messages, msg_list);
|
callback(new_messages, msg_list);
|
||||||
unread_ops.process_visible();
|
unread_ops.process_visible();
|
||||||
|
compose_notifications.notify_messages_outside_current_search(elsewhere_messages);
|
||||||
},
|
},
|
||||||
error(xhr) {
|
error(xhr) {
|
||||||
if (!narrow_state.is_message_feed_visible() || msg_list !== message_lists.current) {
|
if (!narrow_state.is_message_feed_visible() || msg_list !== message_lists.current) {
|
||||||
|
|||||||
Reference in New Issue
Block a user