mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
unread: Handle message edits that affect mentions.
We had a bug where if your peer mentioned you in message, but then edited the message not to mention you, the latter wouldn't reset your unread counts for "Mentions". And the same problem would happen vice versa. The fix basically extracts `update_message_for_mention` and makes sure it handles all combinations of unread/mentioned flags, instead of assuming any invariants about which directions of change are possible. And then we call that new function from `message_events.js` whenever we get message edit events. Fixes #14544
This commit is contained in:
@@ -553,6 +553,40 @@ run_test('mentions', () => {
|
||||
test_notifiable_count(counts.home_unread_messages, 0);
|
||||
});
|
||||
|
||||
run_test('mention updates', () => {
|
||||
const message = {
|
||||
id: 17,
|
||||
unread: false,
|
||||
type: 'stream',
|
||||
};
|
||||
|
||||
function test_counted(counted) {
|
||||
unread.update_message_for_mention(message);
|
||||
assert.equal(
|
||||
unread.unread_mentions_counter.has(message.id),
|
||||
counted
|
||||
);
|
||||
}
|
||||
|
||||
test_counted(false);
|
||||
|
||||
message.unread = true;
|
||||
message.mentioned = true;
|
||||
test_counted(true);
|
||||
|
||||
message.mentioned = false;
|
||||
test_counted(false);
|
||||
|
||||
message.mentioned = true;
|
||||
test_counted(true);
|
||||
|
||||
message.unread = false;
|
||||
test_counted(false);
|
||||
|
||||
message.unread = true;
|
||||
test_counted(true);
|
||||
});
|
||||
|
||||
run_test('starring', () => {
|
||||
// We don't need any setup here, because we just hard code
|
||||
// this to [] in the code.
|
||||
|
||||
Reference in New Issue
Block a user