Get rid of constants activity.user_{active,away,idle}

We don't typically have these (see message type, etc.) and removing
them will allow simplifying the code.

(imported from commit fbefb08ee9b08c73f32c8150a6fa1060957aa8ad)
This commit is contained in:
Keegan McAllister
2013-02-17 13:04:34 -05:00
parent 0b5ba3090a
commit cb45d88cea
2 changed files with 8 additions and 23 deletions

View File

@@ -17,10 +17,6 @@ var IDLE_THRESHOLD_SECS = DEFAULT_IDLE_TIMEOUT_MS / 1000;
/* Keep in sync with views.py:json_update_active_status() */
var ACTIVE = "active";
var IDLE = "idle";
/* Client-side state constants */
exports.user_active = "active";
exports.user_away = "away";
exports.user_idle = "idle";
var has_focus = true;
var ping_timer;
@@ -28,15 +24,15 @@ var ping_timer;
function sort_users(users, user_info) {
// TODO sort by unread count first, once we support that
users.sort(function (a, b) {
if (user_info[a] === exports.user_active && user_info[b] !== exports.user_active) {
if (user_info[a] === 'active' && user_info[b] !== 'active') {
return -1;
} else if (user_info[b] === exports.user_active && user_info[a] !== exports.user_active) {
} else if (user_info[b] === 'active' && user_info[a] !== 'active') {
return 1;
}
if (user_info[a] === exports.user_away && user_info[b] !== exports.user_away) {
if (user_info[a] === 'away' && user_info[b] !== 'away') {
return -1;
} else if (user_info[b] === exports.user_away && user_info[a] !== exports.user_away) {
} else if (user_info[b] === 'away' && user_info[a] !== 'away') {
return 1;
}
@@ -88,13 +84,13 @@ function focus_ping() {
}
if (email !== this_email) {
var status = exports.user_idle;
var status = 'idle';
if (presence.website !== undefined
&& presence.website.status === ACTIVE && age >= 0) {
if (age < AWAY_THRESHOLD_SECS) {
status = exports.user_active;
status = 'active';
} else if (age < IDLE_THRESHOLD_SECS) {
status = exports.user_away;
status = 'away';
}
}
user_info[this_email] = status;