subject -> topic: Make get_event_topic() more flexible.

This commit is contained in:
Steve Howell
2018-12-23 17:08:37 +00:00
committed by Tim Abbott
parent 55b4646212
commit 0c668d13b6
2 changed files with 15 additions and 5 deletions

View File

@@ -105,7 +105,7 @@ run_test('changing_subjects', () => {
assert.deepEqual(msg_ids, []);
var event = {
subject: 'dinner',
topic: 'dinner',
};
unread.update_unread_topics(message, event);
@@ -117,7 +117,7 @@ run_test('changing_subjects', () => {
assert.equal(count, 1);
event = {
subject: 'snack',
topic: 'snack',
};
unread.update_unread_topics(other_message, event);
@@ -135,7 +135,7 @@ run_test('changing_subjects', () => {
// Test defensive code. Trying to update a message we don't know
// about should be a no-op.
event = {
subject: 'brunch',
topic: 'brunch',
};
unread.update_unread_topics(other_message, event);
@@ -167,7 +167,11 @@ run_test('changing_subjects', () => {
assert.equal(count, 0);
assert(!sticky_message.unread);
unread.update_unread_topics(sticky_message, {subject: 'sticky'});
event = {
topic: 'sticky',
};
unread.update_unread_topics(sticky_message, event);
count = unread.num_unread_for_topic(stream_id, 'sticky');
assert.equal(count, 0);

View File

@@ -323,7 +323,13 @@ exports.get_message_topic = function (obj) {
};
exports.get_edit_event_topic = function (obj) {
if (obj.topic === undefined) {
return obj.subject;
}
// This code won't be reachable till we fix the
// server, but we use it now in tests.
return obj.topic;
};
exports.get_edit_event_orig_topic = function (obj) {