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.

compose_closed_ui: Fix incorrect tooltip for new conversation btn.

Aman Agrawal5cfe4829a918
diff --git a/web/src/compose_closed_ui.ts b/web/src/compose_closed_ui.ts
index 697f131fba5..efa72c53299 100644
--- a/web/src/compose_closed_ui.ts
+++ b/web/src/compose_closed_ui.ts
@@ -236,6 +236,18 @@ export function update_recipient_text_for_reply_button(
}
}
+function can_user_reply_to_message(message_id: number): boolean {
+ const selected_message = message_store.get(message_id);
+ if (selected_message === undefined) {
+ return false;
+ }
+ if (selected_message.is_stream) {
+ return !should_disable_compose_reply_button_for_stream();
+ }
+ assert(selected_message.is_private);
+ return message_util.user_can_send_direct_message(selected_message.to_user_ids);
+}
+
export function initialize(): void {
// When the message selection changes, change the label on the Reply button.
$(document).on("message_selected.zulip", () => {
@@ -244,14 +256,9 @@ export function initialize(): void {
// open due to the combined feed view loading in the background,
// so we only update if message feed is visible.
update_recipient_text_for_reply_button();
-
- // Disable compose reply button if the selected message is a stream
- // message and the user is not allowed to post in the stream the message
- // belongs to.
- if (maybe_get_selected_message_stream_id() !== undefined) {
- update_buttons_for_stream_views();
- update_buttons_for_non_specific_views();
- }
+ update_reply_button_state(
+ !can_user_reply_to_message(message_lists.current!.selected_id()),
+ );
}
});
diff --git a/web/tests/compose_closed_ui.test.cjs b/web/tests/compose_closed_ui.test.cjs
index bbe42f81a10..daa3152c891 100644
--- a/web/tests/compose_closed_ui.test.cjs
+++ b/web/tests/compose_closed_ui.test.cjs
@@ -23,7 +23,6 @@ mock_esm("../src/message_list_view", {
MessageListView,
});
mock_esm("../src/settings_data", {
- user_has_permission_for_group_setting: () => true,
user_can_access_all_other_users: () => true,
});