mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	Add current user back to the buddy list.
For many years we have been excluding the current user
from the buddy list, since their presence is kind
of implicit, and it saves a line of real estate.
This commit removes various user-is-me checks
and puts the user back for the following reasons:
    * explicit is better
    * newbies will be less confused when they
      can see they're actually online
    * even long-time users like myself will
      feel more comfortable if it's just there
    * having yourself in the buddy list facilitates
      things like checking your presence or sending
      yourself a message
    * showing "me" reinforces the meaning of the
      green circle (if my circle is green and I'm
      active, then others with green circles must
      be active too)
    * If you're literally the first user in the
      realm, you can now see what the buddy list
      looks like and try out the chevron menu.
The biggest tradeoff here is the opportunity cost.
For an org with more people than fit on the screen,
we put the Nth person below the fold to show "me".
I think that's fine--users can still scroll or
search.
This commit doesn't do anything special with the
current user in terms of sorting them higher in the
list or giving specific styling.
Fixes #10476
			
			
This commit is contained in:
		@@ -473,6 +473,7 @@ function assert_not_selected(name) {
 | 
			
		||||
// User search at the right sidebar
 | 
			
		||||
casper.then(function () {
 | 
			
		||||
    casper.test.info('Search users using right sidebar');
 | 
			
		||||
    assert_in_list('Iago');
 | 
			
		||||
    assert_in_list('Cordelia Lear');
 | 
			
		||||
    assert_in_list('King Hamlet');
 | 
			
		||||
    assert_in_list('aaron');
 | 
			
		||||
@@ -490,7 +491,8 @@ casper.then(function () {
 | 
			
		||||
 | 
			
		||||
casper.waitForSelector('#user_presences .highlighted_user', function () {
 | 
			
		||||
    casper.test.info('Suggestion highlighting - initial situation');
 | 
			
		||||
    assert_selected('Cordelia Lear');
 | 
			
		||||
    assert_selected('Iago');
 | 
			
		||||
    assert_not_selected('Cordelia Lear');
 | 
			
		||||
    assert_not_selected('King Hamlet');
 | 
			
		||||
    assert_not_selected('aaron');
 | 
			
		||||
});
 | 
			
		||||
@@ -502,14 +504,23 @@ casper.then(function () {
 | 
			
		||||
                        casper.page.event.key[key],
 | 
			
		||||
                        {keepFocus: true});
 | 
			
		||||
    }
 | 
			
		||||
    arrow('Down'); // Cordelia -> Hamlet
 | 
			
		||||
    arrow('Up'); // Hamlet -> Cordelia
 | 
			
		||||
    arrow('Up'); // already at top
 | 
			
		||||
    arrow('Down'); // Cordelia -> Hamlet
 | 
			
		||||
 | 
			
		||||
    // go down 2, up 3 (which is really 2), then down 2
 | 
			
		||||
    //    Iago
 | 
			
		||||
    //    Cordelia
 | 
			
		||||
    //    Hamlet
 | 
			
		||||
    arrow('Down');
 | 
			
		||||
    arrow('Down');
 | 
			
		||||
    arrow('Up');
 | 
			
		||||
    arrow('Up');
 | 
			
		||||
    arrow('Up'); // does nothing
 | 
			
		||||
    arrow('Down');
 | 
			
		||||
    arrow('Down');
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
casper.waitForSelector('#user_presences li.highlighted_user [data-name="King Hamlet"]', function () {
 | 
			
		||||
    casper.test.info('Suggestion highlighting - after arrow key navigation');
 | 
			
		||||
    assert_not_selected('Iago');
 | 
			
		||||
    assert_not_selected('Cordelia Lear');
 | 
			
		||||
    assert_selected('King Hamlet');
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
@@ -341,6 +341,7 @@ run_test('presence_list_full_update', () => {
 | 
			
		||||
    assert.deepEqual(user_ids, [
 | 
			
		||||
        fred.user_id,
 | 
			
		||||
        jill.user_id,
 | 
			
		||||
        me.user_id,
 | 
			
		||||
        norbert.user_id,
 | 
			
		||||
        zoe.user_id,
 | 
			
		||||
        alice.user_id,
 | 
			
		||||
@@ -788,11 +789,12 @@ run_test('set_user_status', () => {
 | 
			
		||||
        inserted = true;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    presence.presence_info[alice.user_id] = undefined;
 | 
			
		||||
    presence.presence_info[me.user_id] = undefined;
 | 
			
		||||
    activity.set_user_status(me.email, info, server_time);
 | 
			
		||||
    assert(!inserted);
 | 
			
		||||
    assert(inserted);
 | 
			
		||||
    assert.deepEqual(presence.presence_info[me.user_id].status, 'active');
 | 
			
		||||
 | 
			
		||||
    assert.equal(presence.presence_info[alice.user_id], undefined);
 | 
			
		||||
    presence.presence_info[alice.user_id] = undefined;
 | 
			
		||||
    activity.set_user_status(alice.email, info, server_time);
 | 
			
		||||
    assert(inserted);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,9 +10,7 @@ zrequire('buddy_data');
 | 
			
		||||
// activity.js, but we should feel free to add direct tests
 | 
			
		||||
// here.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
run_test('make_people', () => {
 | 
			
		||||
function make_people() {
 | 
			
		||||
    _.each(_.range(1000, 2000), (i) => {
 | 
			
		||||
        const person = {
 | 
			
		||||
            user_id: i,
 | 
			
		||||
@@ -21,7 +19,17 @@ run_test('make_people', () => {
 | 
			
		||||
        };
 | 
			
		||||
        people.add_in_realm(person);
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
    const bot = {
 | 
			
		||||
        user_id: 55555,
 | 
			
		||||
        full_name: 'Red Herring Bot',
 | 
			
		||||
        email: 'bot@example.com',
 | 
			
		||||
        is_bot: true,
 | 
			
		||||
    };
 | 
			
		||||
    people.add_in_realm(bot);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
make_people();
 | 
			
		||||
 | 
			
		||||
run_test('activate_people', () => {
 | 
			
		||||
    const server_time = 9999;
 | 
			
		||||
 
 | 
			
		||||
@@ -178,11 +178,14 @@ run_test('set_presence_info', () => {
 | 
			
		||||
                     { status: 'idle', mobile: false, last_active: 500}
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    assert.deepEqual(presence.presence_info[me.user_id],
 | 
			
		||||
                     { status: 'active', mobile: false, last_active: 500}
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    assert.deepEqual(presence.presence_info[zoe.user_id],
 | 
			
		||||
                     { status: 'offline', mobile: false, last_active: undefined}
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    assert(!presence.presence_info[me.user_id]);
 | 
			
		||||
    assert(!presence.presence_info[bot.user_id]);
 | 
			
		||||
 | 
			
		||||
    // Make it seem like realm has a lot of people
 | 
			
		||||
 
 | 
			
		||||
@@ -381,10 +381,6 @@ exports.initialize = function () {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.set_user_status = function (email, info, server_time) {
 | 
			
		||||
    if (people.is_current_user(email)) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var user_id = people.get_user_id(email);
 | 
			
		||||
    if (!user_id) {
 | 
			
		||||
        blueslip.warn('unknown email: ' + email);
 | 
			
		||||
 
 | 
			
		||||
@@ -161,8 +161,8 @@ exports.get_filtered_and_sorted_user_ids = function (filter_text) {
 | 
			
		||||
        var person = people.get_person_from_user_id(user_id);
 | 
			
		||||
 | 
			
		||||
        if (person) {
 | 
			
		||||
            // if the user is you or a bot, do not show in presence data.
 | 
			
		||||
            if (person.is_bot || person.user_id === page_params.user_id) {
 | 
			
		||||
            // if the user is bot, do not show in presence data.
 | 
			
		||||
            if (person.is_bot) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -103,10 +103,6 @@ exports.set_info = function (presences, server_timestamp) {
 | 
			
		||||
    _.each(presences, function (info, this_email) {
 | 
			
		||||
        var person = people.get_by_email(this_email);
 | 
			
		||||
 | 
			
		||||
        if (people.is_current_user(this_email)) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (person === undefined) {
 | 
			
		||||
            if (!(server_events.suspect_offline || reload_state.is_in_progress())) {
 | 
			
		||||
                // If we're online, and we get a user who we don't
 | 
			
		||||
@@ -143,10 +139,7 @@ exports.update_info_for_small_realm = function () {
 | 
			
		||||
 | 
			
		||||
    _.each(persons, function (person) {
 | 
			
		||||
        var user_id = person.user_id;
 | 
			
		||||
 | 
			
		||||
        if (people.is_my_user_id(user_id)) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        var status = "offline";
 | 
			
		||||
 | 
			
		||||
        if (presence_info[user_id]) {
 | 
			
		||||
            // this is normal, we have data for active
 | 
			
		||||
@@ -159,8 +152,12 @@ exports.update_info_for_small_realm = function () {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (people.is_my_user_id(user_id)) {
 | 
			
		||||
            status = "active";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        presence_info[user_id] = {
 | 
			
		||||
            status: "offline",
 | 
			
		||||
            status: status,
 | 
			
		||||
            mobile: false,
 | 
			
		||||
            last_active: undefined,
 | 
			
		||||
        };
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user