mirror of
https://github.com/zulip/zulip.git
synced 2025-11-18 12:54:58 +00:00
drafts: Use "topic" internally.
We still have to support "subject" for old drafts, but we write "topic" for new drafts.
This commit is contained in:
@@ -59,9 +59,23 @@ function stub_timestamp(timestamp, func) {
|
||||
Date.prototype.getTime = original_func;
|
||||
}
|
||||
|
||||
var legacy_draft = {
|
||||
stream: "stream",
|
||||
subject: "lunch",
|
||||
type: "stream",
|
||||
content: "whatever",
|
||||
};
|
||||
|
||||
var compose_args_for_legacy_draft = {
|
||||
stream: "stream",
|
||||
subject: "lunch",
|
||||
type: "stream",
|
||||
content: "whatever",
|
||||
};
|
||||
|
||||
var draft_1 = {
|
||||
stream: "stream",
|
||||
subject: "topic",
|
||||
topic: "topic",
|
||||
type: "stream",
|
||||
content: "Test Stream Message",
|
||||
};
|
||||
@@ -78,6 +92,13 @@ var short_msg = {
|
||||
content: "a",
|
||||
};
|
||||
|
||||
run_test('legacy', () => {
|
||||
assert.deepEqual(
|
||||
drafts.restore_message(legacy_draft),
|
||||
compose_args_for_legacy_draft
|
||||
);
|
||||
});
|
||||
|
||||
run_test('draft_model', () => {
|
||||
var draft_model = drafts.draft_model;
|
||||
var ls = localstorage();
|
||||
@@ -148,7 +169,7 @@ run_test('snapshot_message', () => {
|
||||
return draft.stream;
|
||||
};
|
||||
global.compose_state.topic = function () {
|
||||
return draft.subject;
|
||||
return draft.topic;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ exports.snapshot_message = function () {
|
||||
message.private_message_recipient = recipient;
|
||||
} else {
|
||||
message.stream = compose_state.stream_name();
|
||||
message.subject = compose_state.topic();
|
||||
message.topic = compose_state.topic();
|
||||
}
|
||||
return message;
|
||||
};
|
||||
@@ -97,7 +97,7 @@ exports.restore_message = function (draft) {
|
||||
compose_args = {
|
||||
type: 'stream',
|
||||
stream: draft.stream,
|
||||
subject: draft.subject,
|
||||
subject: util.get_draft_topic(draft),
|
||||
content: draft.content,
|
||||
};
|
||||
|
||||
@@ -246,8 +246,11 @@ exports.setup_page = function (callback) {
|
||||
// single space char for proper rendering of the stream label
|
||||
var space_string = new Handlebars.SafeString(" ");
|
||||
var stream = draft.stream.length > 0 ? draft.stream : space_string;
|
||||
var draft_topic = draft.subject.length === 0 ?
|
||||
compose.empty_topic_placeholder() : draft.subject;
|
||||
var draft_topic = util.get_draft_topic(draft);
|
||||
|
||||
if (draft_topic === '') {
|
||||
draft_topic = compose.empty_topic_placeholder();
|
||||
}
|
||||
|
||||
formatted = {
|
||||
draft_id: id,
|
||||
|
||||
@@ -291,6 +291,11 @@ exports.get_match_topic = function (obj) {
|
||||
return obj.match_subject;
|
||||
};
|
||||
|
||||
exports.get_draft_topic = function (obj) {
|
||||
// We will need to support subject for old drafts.
|
||||
return obj.topic || obj.subject || '';
|
||||
};
|
||||
|
||||
exports.set_topic = function (obj, topic) {
|
||||
obj.subject = topic;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user