mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
drafts: Use specific text for DM conversation with self.
Adds "You" and "Drafts from conversations with yourself" as labels in the drafts overlay for the DM conversation with the current user. Co-authored-by: Lauryn Menard <lauryn@zulip.com>
This commit is contained in:
@@ -578,6 +578,7 @@ export type FormattedDraft =
|
||||
}
|
||||
| {
|
||||
is_stream: false;
|
||||
is_dm_with_self: boolean;
|
||||
draft_id: string;
|
||||
recipients: string;
|
||||
raw_content: string;
|
||||
@@ -653,11 +654,19 @@ export function format_draft(draft: LocalStorageDraftWithId): FormattedDraft | u
|
||||
};
|
||||
}
|
||||
|
||||
let is_dm_with_self = false;
|
||||
const emails = util.extract_pm_recipients(draft.private_message_recipient);
|
||||
if (emails.length === 1) {
|
||||
const user = people.get_by_email(emails[0]!);
|
||||
if (user && people.is_direct_message_conversation_with_self([user.user_id])) {
|
||||
is_dm_with_self = true;
|
||||
}
|
||||
}
|
||||
const recipients = people.emails_to_full_names_string(emails);
|
||||
return {
|
||||
draft_id: draft.id,
|
||||
is_stream: false,
|
||||
is_dm_with_self,
|
||||
recipients,
|
||||
raw_content: draft.content,
|
||||
time_stamp,
|
||||
|
@@ -150,6 +150,12 @@ export function launch(): void {
|
||||
function get_header_for_narrow_drafts(): string {
|
||||
const {stream_name, topic, private_recipients} = drafts.current_recipient_data();
|
||||
if (private_recipients) {
|
||||
if (!private_recipients.includes(",")) {
|
||||
const user = people.get_by_email(private_recipients);
|
||||
if (user && people.is_direct_message_conversation_with_self([user.user_id])) {
|
||||
return $t({defaultMessage: "Drafts from conversation with yourself"});
|
||||
}
|
||||
}
|
||||
return $t(
|
||||
{defaultMessage: "Drafts from conversation with {recipient}"},
|
||||
{
|
||||
|
@@ -28,7 +28,11 @@
|
||||
<div class="message-header-contents">
|
||||
<div class="message_label_clickable stream_label">
|
||||
<span class="private_message_header_icon"><i class="zulip-icon zulip-icon-user"></i></span>
|
||||
{{#if is_dm_with_self}}
|
||||
<span class="private_message_header_name">{{t "You" }}</span>
|
||||
{{else}}
|
||||
<span class="private_message_header_name">{{t "You and {recipients}" }}</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="recipient_row_date">{{ time_stamp }}</div>
|
||||
</div>
|
||||
|
@@ -18,7 +18,7 @@ const compose_recipient = zrequire("compose_recipient");
|
||||
const sub_store = zrequire("sub_store");
|
||||
const stream_data = zrequire("stream_data");
|
||||
const {initialize_user_settings} = zrequire("user_settings");
|
||||
const {set_realm} = zrequire("state_data");
|
||||
const {set_current_user, set_realm} = zrequire("state_data");
|
||||
class Clipboard {
|
||||
on() {}
|
||||
}
|
||||
@@ -46,7 +46,9 @@ const zoe = {
|
||||
user_id: 3,
|
||||
full_name: "Zoe",
|
||||
};
|
||||
set_current_user(aaron);
|
||||
people.add_active_user(aaron);
|
||||
people.initialize_current_user(aaron.user_id);
|
||||
people.add_active_user(iago);
|
||||
people.add_active_user(zoe);
|
||||
|
||||
@@ -532,6 +534,7 @@ test("format_drafts", ({override, override_rewire, mock_template}) => {
|
||||
},
|
||||
{
|
||||
draft_id: "id2",
|
||||
is_dm_with_self: true,
|
||||
is_stream: false,
|
||||
recipients: "Aaron",
|
||||
raw_content: "Test direct message",
|
||||
@@ -539,6 +542,7 @@ test("format_drafts", ({override, override_rewire, mock_template}) => {
|
||||
},
|
||||
{
|
||||
draft_id: "id5",
|
||||
is_dm_with_self: false,
|
||||
is_stream: false,
|
||||
recipients: "Iago, Zoe",
|
||||
raw_content: "Test direct message 3",
|
||||
@@ -546,6 +550,7 @@ test("format_drafts", ({override, override_rewire, mock_template}) => {
|
||||
},
|
||||
{
|
||||
draft_id: "id4",
|
||||
is_dm_with_self: false,
|
||||
is_stream: false,
|
||||
recipients: "Iago",
|
||||
raw_content: "Test direct message 2",
|
||||
@@ -713,6 +718,7 @@ test("filter_drafts", ({override, override_rewire, mock_template}) => {
|
||||
const expected_pm_drafts = [
|
||||
{
|
||||
draft_id: "id2",
|
||||
is_dm_with_self: true,
|
||||
is_stream: false,
|
||||
recipients: "Aaron",
|
||||
raw_content: "Test direct message",
|
||||
@@ -720,6 +726,7 @@ test("filter_drafts", ({override, override_rewire, mock_template}) => {
|
||||
},
|
||||
{
|
||||
draft_id: "id5",
|
||||
is_dm_with_self: true,
|
||||
is_stream: false,
|
||||
recipients: "Aaron",
|
||||
raw_content: "Test direct message 3",
|
||||
@@ -727,6 +734,7 @@ test("filter_drafts", ({override, override_rewire, mock_template}) => {
|
||||
},
|
||||
{
|
||||
draft_id: "id4",
|
||||
is_dm_with_self: true,
|
||||
is_stream: false,
|
||||
recipients: "Aaron",
|
||||
raw_content: "Test direct message 2",
|
||||
|
Reference in New Issue
Block a user