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;
|
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 = {
|
var draft_1 = {
|
||||||
stream: "stream",
|
stream: "stream",
|
||||||
subject: "topic",
|
topic: "topic",
|
||||||
type: "stream",
|
type: "stream",
|
||||||
content: "Test Stream Message",
|
content: "Test Stream Message",
|
||||||
};
|
};
|
||||||
@@ -78,6 +92,13 @@ var short_msg = {
|
|||||||
content: "a",
|
content: "a",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
run_test('legacy', () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
drafts.restore_message(legacy_draft),
|
||||||
|
compose_args_for_legacy_draft
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
run_test('draft_model', () => {
|
run_test('draft_model', () => {
|
||||||
var draft_model = drafts.draft_model;
|
var draft_model = drafts.draft_model;
|
||||||
var ls = localstorage();
|
var ls = localstorage();
|
||||||
@@ -148,7 +169,7 @@ run_test('snapshot_message', () => {
|
|||||||
return draft.stream;
|
return draft.stream;
|
||||||
};
|
};
|
||||||
global.compose_state.topic = function () {
|
global.compose_state.topic = function () {
|
||||||
return draft.subject;
|
return draft.topic;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ exports.snapshot_message = function () {
|
|||||||
message.private_message_recipient = recipient;
|
message.private_message_recipient = recipient;
|
||||||
} else {
|
} else {
|
||||||
message.stream = compose_state.stream_name();
|
message.stream = compose_state.stream_name();
|
||||||
message.subject = compose_state.topic();
|
message.topic = compose_state.topic();
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
};
|
};
|
||||||
@@ -97,7 +97,7 @@ exports.restore_message = function (draft) {
|
|||||||
compose_args = {
|
compose_args = {
|
||||||
type: 'stream',
|
type: 'stream',
|
||||||
stream: draft.stream,
|
stream: draft.stream,
|
||||||
subject: draft.subject,
|
subject: util.get_draft_topic(draft),
|
||||||
content: draft.content,
|
content: draft.content,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -246,8 +246,11 @@ exports.setup_page = function (callback) {
|
|||||||
// single space char for proper rendering of the stream label
|
// single space char for proper rendering of the stream label
|
||||||
var space_string = new Handlebars.SafeString(" ");
|
var space_string = new Handlebars.SafeString(" ");
|
||||||
var stream = draft.stream.length > 0 ? draft.stream : space_string;
|
var stream = draft.stream.length > 0 ? draft.stream : space_string;
|
||||||
var draft_topic = draft.subject.length === 0 ?
|
var draft_topic = util.get_draft_topic(draft);
|
||||||
compose.empty_topic_placeholder() : draft.subject;
|
|
||||||
|
if (draft_topic === '') {
|
||||||
|
draft_topic = compose.empty_topic_placeholder();
|
||||||
|
}
|
||||||
|
|
||||||
formatted = {
|
formatted = {
|
||||||
draft_id: id,
|
draft_id: id,
|
||||||
|
|||||||
@@ -291,6 +291,11 @@ exports.get_match_topic = function (obj) {
|
|||||||
return obj.match_subject;
|
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) {
|
exports.set_topic = function (obj, topic) {
|
||||||
obj.subject = topic;
|
obj.subject = topic;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user