mirror of https://github.com/zulip/zulip.git
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
9861cdfeb6
. 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 <p359101898@gmail.com>
This commit is contained in:
parent
19ee1e92e7
commit
1e64aa9b79
|
@ -67,20 +67,6 @@ const {localstorage} = zrequire("localstorage");
|
||||||
const drafts = zrequire("drafts");
|
const drafts = zrequire("drafts");
|
||||||
const timerender = zrequire("timerender");
|
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 = {
|
const draft_1 = {
|
||||||
stream: "stream",
|
stream: "stream",
|
||||||
stream_id: 30,
|
stream_id: 30,
|
||||||
|
@ -96,7 +82,7 @@ const draft_2 = {
|
||||||
};
|
};
|
||||||
const short_msg = {
|
const short_msg = {
|
||||||
stream: "stream",
|
stream: "stream",
|
||||||
subject: "topic",
|
topic: "topic",
|
||||||
type: "stream",
|
type: "stream",
|
||||||
content: "a",
|
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}) => {
|
test("draft_model add", ({override}) => {
|
||||||
const draft_model = drafts.draft_model;
|
const draft_model = drafts.draft_model;
|
||||||
const ls = localstorage();
|
const ls = localstorage();
|
||||||
|
@ -223,7 +205,7 @@ test("initialize", ({override_rewire}) => {
|
||||||
test("remove_old_drafts", () => {
|
test("remove_old_drafts", () => {
|
||||||
const draft_3 = {
|
const draft_3 = {
|
||||||
stream: "stream",
|
stream: "stream",
|
||||||
subject: "topic",
|
topic: "topic",
|
||||||
type: "stream",
|
type: "stream",
|
||||||
content: "Test stream message",
|
content: "Test stream message",
|
||||||
updatedAt: Date.now(),
|
updatedAt: Date.now(),
|
||||||
|
@ -349,7 +331,7 @@ test("format_drafts", ({override_rewire, mock_template}) => {
|
||||||
};
|
};
|
||||||
const draft_3 = {
|
const draft_3 = {
|
||||||
stream: "stream 2",
|
stream: "stream 2",
|
||||||
subject: "topic",
|
topic: "topic",
|
||||||
type: "stream",
|
type: "stream",
|
||||||
content: "Test stream message 2",
|
content: "Test stream message 2",
|
||||||
updatedAt: date(-10),
|
updatedAt: date(-10),
|
||||||
|
@ -490,7 +472,7 @@ test("filter_drafts", ({override_rewire, mock_template}) => {
|
||||||
};
|
};
|
||||||
const stream_draft_2 = {
|
const stream_draft_2 = {
|
||||||
stream: "stream 2",
|
stream: "stream 2",
|
||||||
subject: "topic",
|
topic: "topic",
|
||||||
type: "stream",
|
type: "stream",
|
||||||
content: "Test stream message 2",
|
content: "Test stream message 2",
|
||||||
updatedAt: date(-10),
|
updatedAt: date(-10),
|
||||||
|
|
|
@ -170,7 +170,7 @@ export function restore_message(draft) {
|
||||||
compose_args = {
|
compose_args = {
|
||||||
type: "stream",
|
type: "stream",
|
||||||
stream: draft.stream,
|
stream: draft.stream,
|
||||||
topic: util.get_draft_topic(draft),
|
topic: draft.topic,
|
||||||
content: draft.content,
|
content: draft.content,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
@ -306,13 +306,9 @@ export function format_draft(draft) {
|
||||||
draft_model.editDraft(id, 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);
|
const draft_stream_color = stream_data.get_color(stream_name);
|
||||||
|
|
||||||
if (draft_topic === "") {
|
|
||||||
draft_topic = compose.empty_topic_placeholder();
|
|
||||||
}
|
|
||||||
|
|
||||||
formatted = {
|
formatted = {
|
||||||
draft_id: draft.id,
|
draft_id: draft.id,
|
||||||
is_stream: true,
|
is_stream: true,
|
||||||
|
|
|
@ -217,11 +217,6 @@ export function get_match_topic(obj) {
|
||||||
return obj.match_subject;
|
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) {
|
export function get_reload_topic(obj) {
|
||||||
// When we first upgrade to releases that have
|
// When we first upgrade to releases that have
|
||||||
// topic=foo in the code, the user's reload URL
|
// topic=foo in the code, the user's reload URL
|
||||||
|
|
Loading…
Reference in New Issue