status: buddy list: Add basic UI to show away status.

Right now we do very simple things:

    you: make the green circle empty

    them: make the circle empty and demote to last group
This commit is contained in:
Steve Howell 2018-12-19 20:16:03 +00:00 committed by Tim Abbott
parent bb8750c22b
commit 6507804637
3 changed files with 43 additions and 6 deletions

View File

@ -4,6 +4,7 @@ set_global('page_params', _page_params);
zrequire('people');
zrequire('presence');
zrequire('util');
zrequire('user_status');
zrequire('buddy_data');
zrequire('user_status');
@ -76,6 +77,20 @@ function activate_people() {
make_people();
activate_people();
run_test('buddy_status', () => {
assert.equal(buddy_data.buddy_status(selma.user_id), 'active');
user_status.set_away(selma.user_id);
assert.equal(buddy_data.buddy_status(selma.user_id), 'away_them');
user_status.revoke_away(selma.user_id);
assert.equal(buddy_data.buddy_status(selma.user_id), 'active');
assert.equal(buddy_data.buddy_status(me.user_id), 'active');
user_status.set_away(me.user_id);
assert.equal(buddy_data.buddy_status(me.user_id), 'away_me');
user_status.revoke_away(me.user_id);
assert.equal(buddy_data.buddy_status(me.user_id), 'active');
});
run_test('simple search', () => {
const user_ids = buddy_data.get_filtered_and_sorted_user_ids('sel');
@ -137,7 +152,8 @@ run_test('level', () => {
user_status.set_away(me.user_id);
user_status.set_away(selma.user_id);
// This will change soon for Selma.
// Selma gets demoted to level 3, but "me"
// stays in level 0.
assert.equal(buddy_data.level(me.user_id), 0);
assert.equal(buddy_data.level(selma.user_id), 1);
assert.equal(buddy_data.level(selma.user_id), 3);
});

View File

@ -14,6 +14,8 @@ var exports = {};
exports.max_size_before_shrinking = 600;
var presence_descriptions = {
away_me: 'is away',
away_them: 'is away',
active: 'is active',
idle: 'is not active',
};
@ -36,18 +38,33 @@ exports.level = function (user_id) {
return 0;
}
var status = presence.get_status(user_id);
var status = exports.buddy_status(user_id);
switch (status) {
case 'active':
return 1;
case 'idle':
return 2;
case 'away_them':
return 3;
default:
return 3;
}
};
exports.buddy_status = function (user_id) {
if (user_status.is_away(user_id)) {
if (people.is_my_user_id(user_id)) {
return 'away_me';
}
return 'away_them';
}
// get active/idle/etc.
return presence.get_status(user_id);
};
exports.compare_function = function (a, b) {
var level_a = exports.level(a);
var level_b = exports.level(b);
@ -106,7 +123,7 @@ function get_num_unread(user_id) {
}
exports.info_for = function (user_id) {
var status = presence.get_status(user_id);
var buddy_status = exports.buddy_status(user_id);
var person = people.get_person_from_user_id(user_id);
return {
@ -115,8 +132,8 @@ exports.info_for = function (user_id) {
user_id: user_id,
is_current_user: people.is_my_user_id(user_id),
num_unread: get_num_unread(user_id),
type: status,
type_desc: presence_descriptions[status],
type: buddy_status,
type_desc: presence_descriptions[buddy_status],
};
};

View File

@ -91,6 +91,10 @@
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ec7e18', GradientType=0 ); /* IE6-9; filters only work with hex colors */
}
// We show "away" users identically to long-gone
// users, but this may change.
.user_away_me .user-status-indicator,
.user_away_them .user-status-indicator,
.user-status-indicator {
background-color: none;
border-color: hsl(0, 0%, 50%);