Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
drafts: Show "No DM recipients" when recipients aren't specified.
Harshc6dddfe58041
diff --git a/web/src/drafts.ts b/web/src/drafts.tsindex 37b1f067cc3..3aeaded4d7e 100644--- a/web/src/drafts.ts+++ b/web/src/drafts.ts@@ -578,9 +578,10 @@ export type FormattedDraft =}| {is_stream: false;- is_dm_with_self: boolean;+ is_dm_with_self?: boolean;draft_id: string;recipients: string;+ has_recipient_data: boolean;raw_content: string;time_stamp: string;};@@ -654,6 +655,19 @@ export function format_draft(draft: LocalStorageDraftWithId): FormattedDraft | u};}+ if (draft.private_message_recipient === "") {+ // No users were set as DM recipients when the draft was created.+ return {+ draft_id: draft.id,+ is_stream: false,+ has_recipient_data: false,+ recipients: "",+ raw_content: draft.content,+ time_stamp,+ ...markdown_data,+ };+ }+let is_dm_with_self = false;const emails = util.extract_pm_recipients(draft.private_message_recipient);if (emails.length === 1) {@@ -670,6 +684,7 @@ export function format_draft(draft: LocalStorageDraftWithId): FormattedDraft | urecipients,raw_content: draft.content,time_stamp,+ has_recipient_data: true,...markdown_data,};}diff --git a/web/templates/draft.hbs b/web/templates/draft.hbsindex 1d14b6038a7..1da211a6ead 100644--- a/web/templates/draft.hbs+++ b/web/templates/draft.hbs@@ -31,7 +31,11 @@{{#if is_dm_with_self}}<span class="private_message_header_name">{{t "You" }}</span>{{else}}+ {{#if has_recipient_data}}<span class="private_message_header_name">{{t "You and {recipients}" }}</span>+ {{else}}+ <em>{{t "No DM recipients" }}</em>+ {{/if}}{{/if}}</div><div class="recipient_row_date">{{ time_stamp }}</div>diff --git a/web/tests/drafts.test.cjs b/web/tests/drafts.test.cjsindex 4d911e742f1..2b8d8ce8e1d 100644--- a/web/tests/drafts.test.cjs+++ b/web/tests/drafts.test.cjs@@ -516,6 +516,15 @@ test("format_drafts", ({override, override_rewire, mock_template}) => {is_sending_saving: false,drafts_version: 1,};+ const draft_7 = {+ private_message_recipient: "",+ reply_to: "",+ type: "private",+ content: "Test direct message 4",+ updatedAt: date(-12),+ is_sending_saving: false,+ drafts_version: 1,+ };const expected = [{@@ -536,6 +545,7 @@ test("format_drafts", ({override, override_rewire, mock_template}) => {draft_id: "id2",is_dm_with_self: true,is_stream: false,+ has_recipient_data: true,recipients: "Aaron",raw_content: "Test direct message",time_stamp: "Jan 30",@@ -545,6 +555,7 @@ test("format_drafts", ({override, override_rewire, mock_template}) => {is_dm_with_self: false,is_stream: false,recipients: "Iago, Zoe",+ has_recipient_data: true,raw_content: "Test direct message 3",time_stamp: "Jan 29",},@@ -553,6 +564,7 @@ test("format_drafts", ({override, override_rewire, mock_template}) => {is_dm_with_self: false,is_stream: false,recipients: "Iago",+ has_recipient_data: true,raw_content: "Test direct message 2",time_stamp: "Jan 26",},@@ -584,6 +596,14 @@ test("format_drafts", ({override, override_rewire, mock_template}) => {invite_only: false,is_web_public: false,},+ {+ draft_id: "id7",+ is_stream: false,+ has_recipient_data: false,+ recipients: "",+ raw_content: "Test direct message 4",+ time_stamp: "Jan 19",+ },];$("#drafts_table").append = noop;@@ -597,6 +617,7 @@ test("format_drafts", ({override, override_rewire, mock_template}) => {id4: draft_4,id5: draft_5,id6: draft_6,+ id7: draft_7,};ls.set("drafts", data);assert.deepEqual(draft_model.get(), data);@@ -720,6 +741,7 @@ test("filter_drafts", ({override, override_rewire, mock_template}) => {draft_id: "id2",is_dm_with_self: true,is_stream: false,+ has_recipient_data: true,recipients: "Aaron",raw_content: "Test direct message",time_stamp: "Jan 30",@@ -728,6 +750,7 @@ test("filter_drafts", ({override, override_rewire, mock_template}) => {draft_id: "id5",is_dm_with_self: true,is_stream: false,+ has_recipient_data: true,recipients: "Aaron",raw_content: "Test direct message 3",time_stamp: "Jan 29",@@ -736,6 +759,7 @@ test("filter_drafts", ({override, override_rewire, mock_template}) => {draft_id: "id4",is_dm_with_self: true,is_stream: false,+ has_recipient_data: true,recipients: "Aaron",raw_content: "Test direct message 2",time_stamp: "Jan 26",