mirror of https://github.com/zulip/zulip.git
echo: Fix error during local echo while narrowed to search view.
Earlier, on sending a message while narrowed to a search view '!can_apply_locally()' resulted in error during local echo. Reason: In 'insert_new_messages' the call to 'maybe_add_narrowed_messages' needs message ID to make a GET request to '/messages/matches_narrow', but during local echo message ID is not available. We were using 'local_id' (a float) resulting in 400 error response. Fix: This commit fixes the bug by skipping the discussed GET request during local echo.
This commit is contained in:
parent
3090247221
commit
91e935c695
|
@ -198,7 +198,7 @@ export function insert_local_message(message_request, local_id_float, insert_new
|
|||
|
||||
message.display_recipient = build_display_recipient(message);
|
||||
|
||||
[message] = insert_new_messages([message], true);
|
||||
[message] = insert_new_messages([message], true, true);
|
||||
|
||||
waiting_for_id.set(message.local_id, message);
|
||||
waiting_for_ack.set(message.local_id, message);
|
||||
|
@ -432,6 +432,10 @@ export function process_from_server(messages) {
|
|||
if (msgs_to_rerender_or_add_to_narrow.length > 0) {
|
||||
for (const msg_list of message_lists.all_rendered_message_lists()) {
|
||||
if (!msg_list.data.filter.can_apply_locally()) {
|
||||
// If this message list is a search filter that we
|
||||
// cannot apply locally, we will not have locally
|
||||
// echoed echoed the message at all originally, and
|
||||
// must the server now whether to add it to the view.
|
||||
message_events_util.maybe_add_narrowed_messages(
|
||||
msgs_to_rerender_or_add_to_narrow,
|
||||
msg_list,
|
||||
|
|
|
@ -34,7 +34,7 @@ import * as unread_ops from "./unread_ops";
|
|||
import * as unread_ui from "./unread_ui";
|
||||
import * as util from "./util";
|
||||
|
||||
export function insert_new_messages(messages, sent_by_this_client) {
|
||||
export function insert_new_messages(messages, sent_by_this_client, deliver_locally) {
|
||||
messages = messages.map((message) => message_helper.process_new_message(message));
|
||||
|
||||
const any_untracked_unread_messages = unread.process_loaded_messages(messages, false);
|
||||
|
@ -52,6 +52,17 @@ export function insert_new_messages(messages, sent_by_this_client) {
|
|||
// new messages match the narrow, and use that to
|
||||
// determine which new messages to add to the current
|
||||
// message list (or display a notification).
|
||||
|
||||
if (deliver_locally) {
|
||||
// However, this is a local echo attempt, we can't ask
|
||||
// the server about the match, since we don't have a
|
||||
// final message ID. In that situation, we do nothing
|
||||
// and echo.process_from_server will call
|
||||
// message_events_util.maybe_add_narrowed_messages
|
||||
// once the message is fully delivered.
|
||||
continue;
|
||||
}
|
||||
|
||||
message_events_util.maybe_add_narrowed_messages(
|
||||
messages,
|
||||
list,
|
||||
|
|
|
@ -121,7 +121,7 @@ function get_events_success(events) {
|
|||
// messages, only one of which was sent by this client,
|
||||
// correctly.
|
||||
|
||||
message_events.insert_new_messages(messages, sent_by_this_client);
|
||||
message_events.insert_new_messages(messages, sent_by_this_client, false);
|
||||
}
|
||||
} catch (error) {
|
||||
blueslip.error("Failed to insert new messages", undefined, error);
|
||||
|
|
Loading…
Reference in New Issue