From 1e64aa9b79aa1e63c47094cd319c4ad77aa895ef Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Wed, 28 Sep 2022 15:35:43 -0400 Subject: [PATCH] drafts: Remove support for legacy drafts with "subject". This removes the temporary get_draft_topic helper from utils and remove references to draft.subject. This finishes up the work from 9861cdfeb628366868e6449695cb3a91ae914cbf. Since 2018 we had stopped referring to the "subject" property, it is considered safe to remove this code now. It's impossible to directly upgrade to the current release without substantial downtime for upgrading the OS, so this logic is unlikely to provide any future benefit. Signed-off-by: Zixuan James Li --- frontend_tests/node_tests/drafts.js | 26 ++++---------------------- static/js/drafts.js | 8 ++------ static/js/util.js | 5 ----- 3 files changed, 6 insertions(+), 33 deletions(-) diff --git a/frontend_tests/node_tests/drafts.js b/frontend_tests/node_tests/drafts.js index cecbfa8ebb..775a098aed 100644 --- a/frontend_tests/node_tests/drafts.js +++ b/frontend_tests/node_tests/drafts.js @@ -67,20 +67,6 @@ const {localstorage} = zrequire("localstorage"); const drafts = zrequire("drafts"); const timerender = zrequire("timerender"); -const legacy_draft = { - stream: "stream", - subject: "lunch", - type: "stream", - content: "whatever", -}; - -const compose_args_for_legacy_draft = { - stream: "stream", - topic: "lunch", - type: "stream", - content: "whatever", -}; - const draft_1 = { stream: "stream", stream_id: 30, @@ -96,7 +82,7 @@ const draft_2 = { }; const short_msg = { stream: "stream", - subject: "topic", + topic: "topic", type: "stream", content: "a", }; @@ -109,10 +95,6 @@ function test(label, f) { }); } -test("legacy", () => { - assert.deepEqual(drafts.restore_message(legacy_draft), compose_args_for_legacy_draft); -}); - test("draft_model add", ({override}) => { const draft_model = drafts.draft_model; const ls = localstorage(); @@ -223,7 +205,7 @@ test("initialize", ({override_rewire}) => { test("remove_old_drafts", () => { const draft_3 = { stream: "stream", - subject: "topic", + topic: "topic", type: "stream", content: "Test stream message", updatedAt: Date.now(), @@ -349,7 +331,7 @@ test("format_drafts", ({override_rewire, mock_template}) => { }; const draft_3 = { stream: "stream 2", - subject: "topic", + topic: "topic", type: "stream", content: "Test stream message 2", updatedAt: date(-10), @@ -490,7 +472,7 @@ test("filter_drafts", ({override_rewire, mock_template}) => { }; const stream_draft_2 = { stream: "stream 2", - subject: "topic", + topic: "topic", type: "stream", content: "Test stream message 2", updatedAt: date(-10), diff --git a/static/js/drafts.js b/static/js/drafts.js index c712ef17ef..ab3875c918 100644 --- a/static/js/drafts.js +++ b/static/js/drafts.js @@ -170,7 +170,7 @@ export function restore_message(draft) { compose_args = { type: "stream", stream: draft.stream, - topic: util.get_draft_topic(draft), + topic: draft.topic, content: draft.content, }; } else { @@ -306,13 +306,9 @@ export function format_draft(draft) { draft_model.editDraft(id, draft); } } - let draft_topic = util.get_draft_topic(draft); + const draft_topic = draft.topic || compose.empty_topic_placeholder(); const draft_stream_color = stream_data.get_color(stream_name); - if (draft_topic === "") { - draft_topic = compose.empty_topic_placeholder(); - } - formatted = { draft_id: draft.id, is_stream: true, diff --git a/static/js/util.js b/static/js/util.js index 4171ad41d3..35e6430497 100644 --- a/static/js/util.js +++ b/static/js/util.js @@ -217,11 +217,6 @@ export function get_match_topic(obj) { return obj.match_subject; } -export function get_draft_topic(obj) { - // We will need to support subject for old drafts. - return obj.topic || obj.subject || ""; -} - export function get_reload_topic(obj) { // When we first upgrade to releases that have // topic=foo in the code, the user's reload URL