typeahead: Add pm_conversations module.

In pm_conversations.js, added function to make a user a PM partner and
another function to check if a user is a PM partner. A PM partner is
someone with whom the user has been in a PM with.
This commit is contained in:
Akhil 2017-06-01 05:46:23 +00:00
parent f04da3d52e
commit 64f2b51496
6 changed files with 42 additions and 0 deletions

View File

@ -136,6 +136,7 @@
"current_msg_list": true,
"home_msg_list": false,
"pm_list": false,
"pm_conversations": false,
"recent_senders": false,
"unread_ui": false,
"unread_ops": false,

View File

@ -1,6 +1,7 @@
add_dependencies({
people: 'js/people.js',
util: 'js/util.js',
pm_conversations: 'js/pm_conversations.js',
});
var noop = function () {};

View File

@ -0,0 +1,15 @@
var assert = require('assert');
var pmc = require('js/pm_conversations.js');
(function test_partners() {
var user1_id = 1;
var user2_id = 2;
var user3_id = 3;
pmc.set_partner(user1_id);
pmc.set_partner(user3_id);
assert.equal(pmc.is_partner(user1_id), true);
assert.equal(pmc.is_partner(user2_id), false);
assert.equal(pmc.is_partner(user3_id), true);
}());

View File

@ -49,6 +49,10 @@ exports.process_message_for_recent_private_messages = function (message) {
return;
}
_.each(user_ids, function (user_id) {
pm_conversations.set_partner(user_id);
});
var user_ids_string = user_ids.join(',');
if (!user_ids_string) {

View File

@ -0,0 +1,20 @@
var pm_conversations = (function () {
var exports = {};
var partners = new Dict();
exports.set_partner = function (user_id) {
partners.set(user_id, true);
};
exports.is_partner = function (user_id) {
return partners.get(user_id) || false;
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = pm_conversations;
}

View File

@ -875,6 +875,7 @@ JS_SPECS = {
'js/unread.js',
'js/topic_list.js',
'js/pm_list.js',
'js/pm_conversations.js',
'js/recent_senders.js',
'js/stream_sort.js',
'js/topic_generator.js',