mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Extract people.set_full_name().
This commit is contained in:
		@@ -96,6 +96,12 @@ initialize();
 | 
			
		||||
 | 
			
		||||
    people.update({email: me.email, full_name: 'Me V2'});
 | 
			
		||||
    assert.equal(people.my_full_name(), 'Me V2');
 | 
			
		||||
 | 
			
		||||
    var person = people.get_by_email('me@example.com');
 | 
			
		||||
    people.set_full_name(person, 'Me the Third');
 | 
			
		||||
    assert.equal(people.my_full_name(), 'Me the Third');
 | 
			
		||||
    assert.equal(person.full_name, 'Me the Third');
 | 
			
		||||
    assert.equal(people.get_by_name('Me the Third').email, 'me@example.com');
 | 
			
		||||
}());
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -299,6 +299,14 @@ exports.extract_people_from_message = function (message) {
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.set_full_name = function (person_obj, new_full_name) {
 | 
			
		||||
    if (people_by_name_dict.has(person_obj.full_name)) {
 | 
			
		||||
        people_by_name_dict.del(person_obj.full_name);
 | 
			
		||||
    }
 | 
			
		||||
    people_by_name_dict.set(new_full_name, person_obj);
 | 
			
		||||
    person_obj.full_name = new_full_name;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.update = function update(person) {
 | 
			
		||||
    if (! people_dict.has(person.email)) {
 | 
			
		||||
        blueslip.error("Got update_person event for unexpected user",
 | 
			
		||||
@@ -308,12 +316,7 @@ exports.update = function update(person) {
 | 
			
		||||
    var person_obj = people_dict.get(person.email);
 | 
			
		||||
 | 
			
		||||
    if (_.has(person, 'full_name')) {
 | 
			
		||||
        if (people_by_name_dict.has(person_obj.full_name)) {
 | 
			
		||||
            people_by_name_dict.set(person.full_name, person_obj);
 | 
			
		||||
            people_by_name_dict.del(person_obj.full_name);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        person_obj.full_name = person.full_name;
 | 
			
		||||
        exports.set_full_name(person_obj, person.full_name);
 | 
			
		||||
 | 
			
		||||
        activity.redraw();
 | 
			
		||||
        // TODO: update sender names on messages
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user