widgets: Always render and activate widgets in the current view.

Earlier we did not activate widgets if their rendered HTML was cached,
and also when narrowing to the combined feed view. This caused bugs with
widgets not being activated, and so not responding to any interactions.

Now we unconditionally render and activate widgets in the current view,
irrespective of the cached HTML or the view being narrowed to.
This commit is contained in:
N-Shar-ma
2024-05-07 07:20:04 +05:30
committed by Tim Abbott
parent ebd4468a81
commit 61b3c698af
4 changed files with 14 additions and 53 deletions

View File

@@ -2,6 +2,7 @@ import {z} from "zod";
import * as blueslip from "./blueslip";
import * as channel from "./channel";
import type {MessageList} from "./message_lists";
import * as message_store from "./message_store";
import type {Message} from "./message_store";
import type {Submessage} from "./types";
@@ -87,6 +88,14 @@ export function get_message_events(message: Message): SubmessageEvents | undefin
return clean_events;
}
export function process_widget_rows_in_list(list: MessageList | undefined): void {
for (const message_id of widgetize.widget_contents.keys()) {
if (list?.get(message_id) !== undefined) {
process_submessages({message_id, $row: list.get_row(message_id)});
}
}
}
export function process_submessages(in_opts: {$row: JQuery; message_id: number}): void {
// This happens in our rendering path, so we try to limit any
// damage that may be triggered by one rogue message.