reload: Use "topic" to encode compose topic.

This commit is contained in:
Steve Howell
2018-12-16 17:02:16 +00:00
committed by Tim Abbott
parent 9861cdfeb6
commit 057ee6633a
3 changed files with 16 additions and 2 deletions

View File

@@ -21,6 +21,11 @@ run_test('CachedValue', () => {
}); });
run_test('get_reload_topic', () => {
assert.equal(util.get_reload_topic({subject: 'foo'}), 'foo');
assert.equal(util.get_reload_topic({topic: 'bar'}), 'bar');
});
run_test('extract_pm_recipients', () => { run_test('extract_pm_recipients', () => {
assert.equal(util.extract_pm_recipients('bob@foo.com, alice@foo.com').length, 2); assert.equal(util.extract_pm_recipients('bob@foo.com, alice@foo.com').length, 2);
assert.equal(util.extract_pm_recipients('bob@foo.com, ').length, 1); assert.equal(util.extract_pm_recipients('bob@foo.com, ').length, 1);

View File

@@ -28,7 +28,7 @@ function preserve_state(send_after_reload, save_pointer, save_narrow, save_compo
if (msg_type === 'stream') { if (msg_type === 'stream') {
url += "+msg_type=stream"; url += "+msg_type=stream";
url += "+stream=" + encodeURIComponent(compose_state.stream_name()); url += "+stream=" + encodeURIComponent(compose_state.stream_name());
url += "+subject=" + encodeURIComponent(compose_state.topic()); url += "+topic=" + encodeURIComponent(compose_state.topic());
} else if (msg_type === 'private') { } else if (msg_type === 'private') {
url += "+msg_type=private"; url += "+msg_type=private";
url += "+recipient=" + encodeURIComponent(compose_state.recipient()); url += "+recipient=" + encodeURIComponent(compose_state.recipient());
@@ -131,8 +131,10 @@ exports.initialize = function () {
try { try {
// TODO: preserve focus // TODO: preserve focus
var topic = util.get_reload_topic(vars);
compose_actions.start(vars.msg_type, {stream: vars.stream || '', compose_actions.start(vars.msg_type, {stream: vars.stream || '',
subject: vars.subject || '', subject: topic || '',
private_message_recipient: vars.recipient || '', private_message_recipient: vars.recipient || '',
content: vars.msg || ''}); content: vars.msg || ''});
if (send_now) { if (send_now) {

View File

@@ -296,6 +296,13 @@ exports.get_draft_topic = function (obj) {
return obj.topic || obj.subject || ''; return obj.topic || obj.subject || '';
}; };
exports.get_reload_topic = function (obj) {
// When we first upgrade to releases that have
// topic=foo in the code, the user's reload URL
// may still have subject=foo from the prior version.
return obj.topic || obj.subject || '';
};
exports.set_topic = function (obj, topic) { exports.set_topic = function (obj, topic) {
obj.subject = topic; obj.subject = topic;
}; };