refactor: Extract pm_conversations.recent.

This is a pretty pure code move, where we moved stuff from
message_store to pm_conversations:

    insert_recent_private_message() -> recent.insert()
    recent_private_messages -> recent.get()

The object message_store.recent_private_messages was not
encapsulated in a function before this change.  Now it is
hidden in the scope of pm_conversations.recent.

Both of the modules touched here maintain 100% line coverage.
This commit is contained in:
Steve Howell
2018-02-09 12:10:39 -05:00
committed by Tim Abbott
parent a0b58b1560
commit 4f52e095e8
6 changed files with 63 additions and 57 deletions

View File

@@ -60,20 +60,6 @@ people.add_in_realm(cindy);
global.people.initialize_current_user(me.user_id);
(function test_insert_recent_private_message() {
message_store.insert_recent_private_message('1', 1001);
message_store.insert_recent_private_message('2', 2001);
message_store.insert_recent_private_message('1', 3001);
// try to backdate user1's timestamp
message_store.insert_recent_private_message('1', 555);
assert.deepEqual(message_store.recent_private_messages, [
{user_ids_string: '1', timestamp: 3001},
{user_ids_string: '2', timestamp: 2001},
]);
}());
(function test_add_message_metadata() {
var message = {
sender_email: 'me@example.com',