mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	refactor: Use user_id as key for pm_recipient_count.
We now key people.pm_recipient_count by user_id, which makes one less dictionary that we'll need to update when we support email updates.
This commit is contained in:
		@@ -60,8 +60,21 @@ global.people.add({
 | 
			
		||||
    assert_typeahead_equals("test no@o", false);
 | 
			
		||||
    assert_typeahead_equals("test :-P", false);
 | 
			
		||||
 | 
			
		||||
    var all_items = [{ special_item_text: 'all (Notify everyone)', email: 'all', pm_recipient_count: Infinity, full_name: 'all' },
 | 
			
		||||
                     { special_item_text: 'everyone (Notify everyone)', email: 'everyone', full_name: 'everyone' }];
 | 
			
		||||
    var all_items = [
 | 
			
		||||
        {
 | 
			
		||||
            special_item_text: 'all (Notify everyone)',
 | 
			
		||||
            email: 'all',
 | 
			
		||||
            pm_recipient_count: Infinity,
 | 
			
		||||
            full_name: 'all',
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            special_item_text: 'everyone (Notify everyone)',
 | 
			
		||||
            email: 'everyone',
 | 
			
		||||
            pm_recipient_count: Infinity,
 | 
			
		||||
            full_name: 'everyone',
 | 
			
		||||
        },
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    var people_with_all = global.people.get_realm_persons().concat(all_items);
 | 
			
		||||
 | 
			
		||||
    assert_typeahead_equals("test @o", people_with_all);
 | 
			
		||||
 
 | 
			
		||||
@@ -135,11 +135,11 @@ initialize();
 | 
			
		||||
initialize();
 | 
			
		||||
 | 
			
		||||
(function test_recipient_counts() {
 | 
			
		||||
    var email = 'anybody@example.com';
 | 
			
		||||
    assert.equal(people.get_recipient_count({email: email}), 0);
 | 
			
		||||
    people.incr_recipient_count(email);
 | 
			
		||||
    people.incr_recipient_count(email);
 | 
			
		||||
    assert.equal(people.get_recipient_count({email: email}), 2);
 | 
			
		||||
    var user_id = 99;
 | 
			
		||||
    assert.equal(people.get_recipient_count({id: user_id}), 0);
 | 
			
		||||
    people.incr_recipient_count(user_id);
 | 
			
		||||
    people.incr_recipient_count(user_id);
 | 
			
		||||
    assert.equal(people.get_recipient_count({user_id: user_id}), 2);
 | 
			
		||||
 | 
			
		||||
    assert.equal(people.get_recipient_count({pm_recipient_count: 5}), 5);
 | 
			
		||||
}());
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user