From 6f0477f491dacc4c88b1559949bd2d55a23d13a7 Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Thu, 5 Dec 2013 16:20:20 -0500 Subject: [PATCH] Increase number of names shown in group PM list from 2 to 3 (imported from commit eff308fb1405290488f74d9064fd859d33c99558) --- static/js/activity.js | 5 +++-- zerver/tests/frontend/node/activity.js | 13 +++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/static/js/activity.js b/static/js/activity.js index 5df6fdc20a..5f5b348d52 100644 --- a/static/js/activity.js +++ b/static/js/activity.js @@ -77,11 +77,12 @@ exports.full_huddle_name = function (huddle) { exports.short_huddle_name = function (huddle) { var emails = huddle.split(','); - var names = _.map(emails.slice(0,2), function (email) { + var num_to_show = 3; + var names = _.map(emails.slice(0, num_to_show), function (email) { var person = people_dict.get(email); return person ? person.full_name : email; }); - var others = emails.length - 2; + var others = emails.length - num_to_show; if (others === 1) { names.push("+ 1 other"); diff --git a/zerver/tests/frontend/node/activity.js b/zerver/tests/frontend/node/activity.js index 8f535516bf..648fa0094a 100644 --- a/zerver/tests/frontend/node/activity.js +++ b/zerver/tests/frontend/node/activity.js @@ -32,6 +32,9 @@ set_global('people_dict', new global.Dict.from({ }, 'mark@zulip.com': { full_name: 'Marky Mark' + }, + 'norbert@zulip.com': { + full_name: 'Norbert Oswald' } })); @@ -120,13 +123,19 @@ var activity = require('js/activity.js'); assert.equal( activity.short_huddle_name('alice@zulip.com,fred@zulip.com,jill@zulip.com'), - 'Alice Smith, Fred Flintstone, + 1 other' + 'Alice Smith, Fred Flintstone, Jill Hill' ); assert.equal( activity.short_huddle_name('alice@zulip.com,fred@zulip.com,jill@zulip.com,mark@zulip.com'), - 'Alice Smith, Fred Flintstone, + 2 others' + 'Alice Smith, Fred Flintstone, Jill Hill, + 1 other' ); + + assert.equal( + activity.short_huddle_name('alice@zulip.com,fred@zulip.com,jill@zulip.com,mark@zulip.com,norbert@zulip.com'), + 'Alice Smith, Fred Flintstone, Jill Hill, + 2 others' + ); + }()); (function test_huddle_fraction_present() {