bug fix: Fix huddles in "Private Messages".

If two user_ids in a recent huddle have ids
that sort lexically differently than numerically,
such as 7 and 66, then we were creating two
different buckets in pm_conversations.

This regression was introduced in
263ac0eb45 on
November 21, 2019.
This commit is contained in:
Steve Howell
2020-01-01 14:55:36 +00:00
committed by Tim Abbott
parent 71dae1b92a
commit aed813f44c
2 changed files with 5 additions and 3 deletions

View File

@@ -33,7 +33,7 @@ run_test('insert_recent_private_message', () => {
pmc.recent.initialize(); pmc.recent.initialize();
assert.deepEqual(pmc.recent.get(), [ assert.deepEqual(pmc.recent.get(), [
{user_ids_string: '11,2', max_message_id: 150}, {user_ids_string: '2,11', max_message_id: 150},
{user_ids_string: '1', max_message_id: 111}, {user_ids_string: '1', max_message_id: 111},
{user_ids_string: '15', max_message_id: 7}, {user_ids_string: '15', max_message_id: 7},
]); ]);
@@ -48,9 +48,9 @@ run_test('insert_recent_private_message', () => {
assert.deepEqual(pmc.recent.get(), [ assert.deepEqual(pmc.recent.get(), [
{user_ids_string: '1', max_message_id: 3001}, {user_ids_string: '1', max_message_id: 3001},
{user_ids_string: '2', max_message_id: 2001}, {user_ids_string: '2', max_message_id: 2001},
{user_ids_string: '11,2', max_message_id: 150}, {user_ids_string: '2,11', max_message_id: 150},
{user_ids_string: '15', max_message_id: 7}, {user_ids_string: '15', max_message_id: 7},
]); ]);
assert.deepEqual(pmc.recent.get_strings(), ['1', '2', '11,2', '15']); assert.deepEqual(pmc.recent.get_strings(), ['1', '2', '2,11', '15']);
}); });

View File

@@ -23,6 +23,8 @@ exports.recent = (function () {
// The server sends [] for self-PMs. // The server sends [] for self-PMs.
user_ids = [people.my_current_user_id()]; user_ids = [people.my_current_user_id()];
} }
user_ids.sort((a, b) => a - b);
const user_ids_string = user_ids.join(','); const user_ids_string = user_ids.join(',');
let conversation = recent_message_ids.get(user_ids_string); let conversation = recent_message_ids.get(user_ids_string);