mirror of
https://github.com/zulip/zulip.git
synced 2025-10-31 20:13:46 +00:00
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:
committed by
Tim Abbott
parent
a8f0cb2cf9
commit
ffa9c1e6a3
@@ -7,12 +7,14 @@ import type {
|
|||||||
QuestionOutboundData,
|
QuestionOutboundData,
|
||||||
VoteOutboundData,
|
VoteOutboundData,
|
||||||
} from "../shared/src/poll_data.ts";
|
} 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 from "../templates/widgets/poll_widget.hbs";
|
||||||
import render_widgets_poll_widget_results from "../templates/widgets/poll_widget_results.hbs";
|
import render_widgets_poll_widget_results from "../templates/widgets/poll_widget_results.hbs";
|
||||||
|
|
||||||
import * as blueslip from "./blueslip.ts";
|
import * as blueslip from "./blueslip.ts";
|
||||||
import {$t} from "./i18n.ts";
|
import {$t} from "./i18n.ts";
|
||||||
import * as keydown_util from "./keydown_util.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 type {Message} from "./message_store.ts";
|
||||||
import * as people from "./people.ts";
|
import * as people from "./people.ts";
|
||||||
|
|
||||||
@@ -49,6 +51,7 @@ export function activate({
|
|||||||
comma_separated_names: people.get_full_names_for_poll_option,
|
comma_separated_names: people.get_full_names_for_poll_option,
|
||||||
report_error_function: blueslip.warn,
|
report_error_function: blueslip.warn,
|
||||||
});
|
});
|
||||||
|
const message_container = message_lists.current?.view.message_containers.get(message.id);
|
||||||
|
|
||||||
function update_edit_controls(): void {
|
function update_edit_controls(): void {
|
||||||
const has_question =
|
const has_question =
|
||||||
@@ -230,6 +233,12 @@ export function activate({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handle_events = function (events: Event[]): void {
|
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) {
|
for (const event of events) {
|
||||||
poll_data.handle_event(event.sender_id, event.data);
|
poll_data.handle_event(event.sender_id, event.data);
|
||||||
}
|
}
|
||||||
@@ -238,9 +247,14 @@ export function activate({
|
|||||||
render_results();
|
render_results();
|
||||||
};
|
};
|
||||||
|
|
||||||
build_widget();
|
if (message_container?.is_hidden) {
|
||||||
render_question();
|
const html = render_message_hidden_dialog();
|
||||||
render_results();
|
$elem.html(html);
|
||||||
|
} else {
|
||||||
|
build_widget();
|
||||||
|
render_question();
|
||||||
|
render_results();
|
||||||
|
}
|
||||||
|
|
||||||
return handle_events;
|
return handle_events;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,13 @@ import _ from "lodash";
|
|||||||
import assert from "minimalistic-assert";
|
import assert from "minimalistic-assert";
|
||||||
import * as z from "zod/mini";
|
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 from "../templates/widgets/todo_widget.hbs";
|
||||||
import render_widgets_todo_widget_tasks from "../templates/widgets/todo_widget_tasks.hbs";
|
import render_widgets_todo_widget_tasks from "../templates/widgets/todo_widget_tasks.hbs";
|
||||||
|
|
||||||
import * as blueslip from "./blueslip.ts";
|
import * as blueslip from "./blueslip.ts";
|
||||||
import {$t} from "./i18n.ts";
|
import {$t} from "./i18n.ts";
|
||||||
|
import * as message_lists from "./message_lists.ts";
|
||||||
import type {Message} from "./message_store.ts";
|
import type {Message} from "./message_store.ts";
|
||||||
import {page_params} from "./page_params.ts";
|
import {page_params} from "./page_params.ts";
|
||||||
import * as people from "./people.ts";
|
import * as people from "./people.ts";
|
||||||
@@ -342,6 +344,7 @@ export function activate({
|
|||||||
tasks,
|
tasks,
|
||||||
report_error_function: blueslip.warn,
|
report_error_function: blueslip.warn,
|
||||||
});
|
});
|
||||||
|
const message_container = message_lists.current?.view.message_containers.get(message.id);
|
||||||
|
|
||||||
function update_edit_controls(): void {
|
function update_edit_controls(): void {
|
||||||
const has_title =
|
const has_title =
|
||||||
@@ -521,6 +524,12 @@ export function activate({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handle_events = function (events: Event[]): void {
|
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) {
|
for (const event of events) {
|
||||||
task_data.handle_event(event.sender_id, event.data);
|
task_data.handle_event(event.sender_id, event.data);
|
||||||
}
|
}
|
||||||
@@ -529,9 +538,14 @@ export function activate({
|
|||||||
render_results();
|
render_results();
|
||||||
};
|
};
|
||||||
|
|
||||||
build_widget();
|
if (message_container?.is_hidden) {
|
||||||
render_task_list_title();
|
const html = render_message_hidden_dialog();
|
||||||
render_results();
|
$elem.html(html);
|
||||||
|
} else {
|
||||||
|
build_widget();
|
||||||
|
render_task_list_title();
|
||||||
|
render_results();
|
||||||
|
}
|
||||||
|
|
||||||
return handle_events;
|
return handle_events;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user