mirror of https://github.com/zulip/zulip.git
[important] Fix stacktrace in unread.js.
There is a scenario where we call process_read_message() for a message that we haven't recorded as unread before. I'm not sure how it happens, but I put back code to guard against crashing. The regression happened in 5752458c821. (imported from commit 5ce15d2e236b738b445ed88f1733aa0612be0ff3)
This commit is contained in:
parent
bbfc8c886a
commit
8f1498c766
|
@ -72,7 +72,13 @@ exports.process_read_message = function (message) {
|
||||||
if (message.type === 'stream') {
|
if (message.type === 'stream') {
|
||||||
var canon_stream = stream_data.canonicalized_name(message.stream);
|
var canon_stream = stream_data.canonicalized_name(message.stream);
|
||||||
var canon_subject = stream_data.canonicalized_name(message.subject);
|
var canon_subject = stream_data.canonicalized_name(message.subject);
|
||||||
unread_subjects.get(canon_stream).get(canon_subject).del(message.id);
|
var stream_dict = unread_subjects.get(canon_stream);
|
||||||
|
if (stream_dict) {
|
||||||
|
var subject_dict = stream_dict.get(canon_subject);
|
||||||
|
if (subject_dict) {
|
||||||
|
subject_dict.del(message.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unread_mentioned.del(message.id);
|
unread_mentioned.del(message.id);
|
||||||
};
|
};
|
||||||
|
|
|
@ -215,6 +215,19 @@ var zero_counts = {
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
(function test_phantom_messages() {
|
||||||
|
var message = {
|
||||||
|
id: 999,
|
||||||
|
type: 'stream',
|
||||||
|
stream: 'foo',
|
||||||
|
subject: 'phantom'
|
||||||
|
};
|
||||||
|
|
||||||
|
unread.process_read_message(message);
|
||||||
|
var counts = unread.get_counts();
|
||||||
|
assert.equal(counts.home_unread_messages, 0);
|
||||||
|
}());
|
||||||
|
|
||||||
(function test_private_messages() {
|
(function test_private_messages() {
|
||||||
narrow.active = function () {
|
narrow.active = function () {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue