Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_view: Reset id_info to avoid potential bugs.

Aman Agrawale85a33cc9561
diff --git a/web/src/message_view.ts b/web/src/message_view.ts
index b7a4d5f6338..2cc204ba1f0 100644
--- a/web/src/message_view.ts
+++ b/web/src/message_view.ts
@@ -175,12 +175,15 @@ function create_and_update_message_list(
excludes_muted_topics,
});
+ const original_id_info = {...id_info};
// Populate the message list if we can apply our filter locally (i.e.
// with no server help) and we have the message we want to select.
// Also update id_info accordingly.
if (!filter.requires_adjustment_for_moved_with_target) {
const superset_datasets = message_list_data_cache.get_superset_datasets(filter);
for (const superset_data of superset_datasets) {
+ // Reset properties that might have been set.
+ id_info = Object.assign(id_info, original_id_info);
maybe_add_local_messages({
id_info,
msg_data,
@@ -352,6 +355,14 @@ export type ShowMessageViewOpts = {
show_more_topics?: boolean;
};
+export function get_id_info(): TargetMessageIdInfo {
+ return {
+ target_id: undefined,
+ final_select_id: undefined,
+ local_select_id: undefined,
+ };
+}
+
export let show = (raw_terms: NarrowTerm[], show_opts: ShowMessageViewOpts): void => {
/* Main entry point for switching to a new view / message list.
@@ -453,12 +464,7 @@ export let show = (raw_terms: NarrowTerm[], show_opts: ShowMessageViewOpts): voi
data: {raw_terms, trigger: opts.trigger},
};
void Sentry.startSpan({...span_data, name: "narrow"}, async (span) => {
- const id_info: TargetMessageIdInfo = {
- target_id: undefined,
- local_select_id: undefined,
- final_select_id: undefined,
- };
-
+ const id_info = get_id_info();
const terms = filter.terms();
// These two narrowing operators specify what message should be