Skip to content

Commit

Permalink
user_popover: Handle the case when user presence is unknown.
Browse files Browse the repository at this point in the history
For bots and users who have not logged in for a long time the presence information is not known. For the these users make the presence indicator hidden.
  • Loading branch information
hackerkid committed Jun 19, 2017
1 parent 7e99262 commit 9f7cae4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
11 changes: 6 additions & 5 deletions static/js/popovers.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ function load_medium_avatar(user_email) {
}

function user_last_seen_time_status(user_id) {
if (presence.get_status(user_id) === "active") {
var status = presence.get_status(user_id);
if (status === "active") {
return i18n.t("Active now");
}

if (people.get_person_from_user_id(user_id).is_bot) {
return i18n.t("Bot");
if (status === "unknown") {
// We are not using this anywhere right now as the user presence indicator
// is hidden for this case
return i18n.t("Unknown");
}

return timerender.last_seen_status_from_date(presence.last_active_date(user_id).clone());
}

Expand Down
5 changes: 4 additions & 1 deletion static/js/presence.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ exports.get_status = function (user_id) {
if (user_id === page_params.user_id) {
return "active";
}
return exports.presence_info[user_id].status;
if (user_id in exports.presence_info) {
return exports.presence_info[user_id].status;
}
return "unknown";
};

exports.get_mobile = function (user_id) {
Expand Down
4 changes: 4 additions & 0 deletions static/styles/right-sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
border-color: gray;
}

.user_unknown .user-status-indicator {
display: none;
}

#user_presences a,
#group-pms a {
color: inherit;
Expand Down

0 comments on commit 9f7cae4

Please sign in to comment.