mirror of https://github.com/zulip/zulip.git
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:
parent
f04da3d52e
commit
64f2b51496
|
@ -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,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
add_dependencies({
|
||||
people: 'js/people.js',
|
||||
util: 'js/util.js',
|
||||
pm_conversations: 'js/pm_conversations.js',
|
||||
});
|
||||
|
||||
var noop = function () {};
|
||||
|
|
|
@ -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);
|
||||
}());
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue