mirror of
https://github.com/zulip/zulip.git
synced 2025-11-21 15:09:34 +00:00
search: Link messages in search results to near view.
Previously clicking on a message in search results opened the compose box. This was not great, because search views show messages outside of their context, and replying to a message without the context of possible more recent messages sent to that narrow can result in a bad experience. This commit prevents the composebox from opening on click and instead moves the user to a near view for the message, and similarly with the enter keyboard shortcut. Fixes #21217.
This commit is contained in:
@@ -23,6 +23,7 @@ import * as message_edit from "./message_edit";
|
||||
import * as message_lists from "./message_lists";
|
||||
import * as message_store from "./message_store";
|
||||
import * as narrow from "./narrow";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as navigate from "./navigate";
|
||||
import {page_params} from "./page_params";
|
||||
import * as pm_list from "./pm_list";
|
||||
@@ -184,6 +185,21 @@ export function initialize() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clicks on a message from search results should bring the
|
||||
// user to the message's near view instead of opening the
|
||||
// compose box.
|
||||
const current_filter = narrow_state.filter();
|
||||
if (current_filter !== undefined && !current_filter.supports_collapsing_recipients()) {
|
||||
const message = message_store.get(id);
|
||||
|
||||
if (message === undefined) {
|
||||
// This might happen for locally echoed messages, for example.
|
||||
return;
|
||||
}
|
||||
window.location = hash_util.by_conversation_and_time_url(message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (page_params.is_spectator) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user