refactor: Simplify user_last_seen_time_status().

We are about to stop supporting the presence status of "unknown."
Part of this fix is to stop checking for that status.

The implication of this change is that when we go
to display the time a user was last online, we now
mostly just look to see if presence.last_active_date
is undefined.  We were wary of that approach before, but it
is probably the most sane approach here.

I updated the comment abover this section to reflect
our philosophy going forward.

BTW the timestamp is kind of buried in the UI for now, as you have to
open the popover and then hover over the circular presence
indicator.
This commit is contained in:
Steve Howell
2017-10-12 08:50:41 -07:00
committed by Tim Abbott
parent f0194f1821
commit 8593c25f45

View File

@@ -47,20 +47,18 @@ function user_last_seen_time_status(user_id) {
if (status === "active") {
return i18n.t("Active now");
}
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");
}
if (page_params.realm_is_zephyr_mirror_realm) {
// We don't send presence data to clients in Zephyr mirroring realms
return i18n.t("Unknown");
}
// TODO: If the user account has been deactivated, it won't appear
// in the presence data set. Ideally, we'd have a cleaner
// solution that had us understand that state declaratively and
// thus not need this check (see #4322).
// There are situations where the client has incomplete presence
// history on a user. This can happen when users are deactivated,
// or when they just haven't been present in a long time (and we
// may have queries on presence that go back only N weeks).
//
// We give the somewhat vague status of "Unknown" for these users.
var last_active_date = presence.last_active_date(user_id);
if (last_active_date === undefined) {
return i18n.t("Unknown");