widget: Hide widgets from muted users like normal messages.

Earlier, messages from muted users were hidden with a hidden dialog
but widgets were still visible.

This commit corrects this behaviour by hiding it if the message
container is supposed to be hidden.

Fixes part of zulip#34886.
This commit is contained in:
Pratik Chanda
2025-07-04 15:06:56 +05:30
committed by Tim Abbott
parent a8f0cb2cf9
commit ffa9c1e6a3
2 changed files with 34 additions and 6 deletions

View File

@@ -7,12 +7,14 @@ import type {
QuestionOutboundData,
VoteOutboundData,
} from "../shared/src/poll_data.ts";
import render_message_hidden_dialog from "../templates/message_hidden_dialog.hbs";
import render_widgets_poll_widget from "../templates/widgets/poll_widget.hbs";
import render_widgets_poll_widget_results from "../templates/widgets/poll_widget_results.hbs";
import * as blueslip from "./blueslip.ts";
import {$t} from "./i18n.ts";
import * as keydown_util from "./keydown_util.ts";
import * as message_lists from "./message_lists.ts";
import type {Message} from "./message_store.ts";
import * as people from "./people.ts";
@@ -49,6 +51,7 @@ export function activate({
comma_separated_names: people.get_full_names_for_poll_option,
report_error_function: blueslip.warn,
});
const message_container = message_lists.current?.view.message_containers.get(message.id);
function update_edit_controls(): void {
const has_question =
@@ -230,6 +233,12 @@ export function activate({
}
const handle_events = function (events: Event[]): void {
// We don't have to handle events now since we go through
// handle_event loop again when we unmute the message.
if (message_container?.is_hidden) {
return;
}
for (const event of events) {
poll_data.handle_event(event.sender_id, event.data);
}
@@ -238,9 +247,14 @@ export function activate({
render_results();
};
build_widget();
render_question();
render_results();
if (message_container?.is_hidden) {
const html = render_message_hidden_dialog();
$elem.html(html);
} else {
build_widget();
render_question();
render_results();
}
return handle_events;
}

View File

@@ -3,11 +3,13 @@ import _ from "lodash";
import assert from "minimalistic-assert";
import * as z from "zod/mini";
import render_message_hidden_dialog from "../templates/message_hidden_dialog.hbs";
import render_widgets_todo_widget from "../templates/widgets/todo_widget.hbs";
import render_widgets_todo_widget_tasks from "../templates/widgets/todo_widget_tasks.hbs";
import * as blueslip from "./blueslip.ts";
import {$t} from "./i18n.ts";
import * as message_lists from "./message_lists.ts";
import type {Message} from "./message_store.ts";
import {page_params} from "./page_params.ts";
import * as people from "./people.ts";
@@ -342,6 +344,7 @@ export function activate({
tasks,
report_error_function: blueslip.warn,
});
const message_container = message_lists.current?.view.message_containers.get(message.id);
function update_edit_controls(): void {
const has_title =
@@ -521,6 +524,12 @@ export function activate({
}
const handle_events = function (events: Event[]): void {
// We don't have to handle events now since we go through
// handle_event loop again when we unmute the message.
if (message_container?.is_hidden) {
return;
}
for (const event of events) {
task_data.handle_event(event.sender_id, event.data);
}
@@ -529,9 +538,14 @@ export function activate({
render_results();
};
build_widget();
render_task_list_title();
render_results();
if (message_container?.is_hidden) {
const html = render_message_hidden_dialog();
$elem.html(html);
} else {
build_widget();
render_task_list_title();
render_results();
}
return handle_events;
}