mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	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:
		@@ -136,6 +136,7 @@
 | 
				
			|||||||
        "current_msg_list": true,
 | 
					        "current_msg_list": true,
 | 
				
			||||||
        "home_msg_list": false,
 | 
					        "home_msg_list": false,
 | 
				
			||||||
        "pm_list": false,
 | 
					        "pm_list": false,
 | 
				
			||||||
 | 
					        "pm_conversations": false,
 | 
				
			||||||
        "recent_senders": false,
 | 
					        "recent_senders": false,
 | 
				
			||||||
        "unread_ui": false,
 | 
					        "unread_ui": false,
 | 
				
			||||||
        "unread_ops": false,
 | 
					        "unread_ops": false,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
add_dependencies({
 | 
					add_dependencies({
 | 
				
			||||||
    people: 'js/people.js',
 | 
					    people: 'js/people.js',
 | 
				
			||||||
    util: 'js/util.js',
 | 
					    util: 'js/util.js',
 | 
				
			||||||
 | 
					    pm_conversations: 'js/pm_conversations.js',
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var noop = function () {};
 | 
					var noop = function () {};
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										15
									
								
								frontend_tests/node_tests/pm_conversations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								frontend_tests/node_tests/pm_conversations.js
									
									
									
									
									
										Normal 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);
 | 
				
			||||||
 | 
					}());
 | 
				
			||||||
@@ -49,6 +49,10 @@ exports.process_message_for_recent_private_messages = function (message) {
 | 
				
			|||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    _.each(user_ids, function (user_id) {
 | 
				
			||||||
 | 
					        pm_conversations.set_partner(user_id);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var user_ids_string = user_ids.join(',');
 | 
					    var user_ids_string = user_ids.join(',');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!user_ids_string) {
 | 
					    if (!user_ids_string) {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										20
									
								
								static/js/pm_conversations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								static/js/pm_conversations.js
									
									
									
									
									
										Normal 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;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -875,6 +875,7 @@ JS_SPECS = {
 | 
				
			|||||||
            'js/unread.js',
 | 
					            'js/unread.js',
 | 
				
			||||||
            'js/topic_list.js',
 | 
					            'js/topic_list.js',
 | 
				
			||||||
            'js/pm_list.js',
 | 
					            'js/pm_list.js',
 | 
				
			||||||
 | 
					            'js/pm_conversations.js',
 | 
				
			||||||
            'js/recent_senders.js',
 | 
					            'js/recent_senders.js',
 | 
				
			||||||
            'js/stream_sort.js',
 | 
					            'js/stream_sort.js',
 | 
				
			||||||
            'js/topic_generator.js',
 | 
					            'js/topic_generator.js',
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user