2018-12-19 17:11:17 +01:00
|
|
|
var user_status = (function () {
|
|
|
|
|
|
|
|
var exports = {};
|
|
|
|
|
|
|
|
var away_user_ids = new Dict();
|
|
|
|
|
|
|
|
exports.server_set_away = function () {
|
|
|
|
channel.post({
|
|
|
|
url: '/json/users/me/status',
|
|
|
|
data: {away: true},
|
|
|
|
idempotent: true,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.server_revoke_away = function () {
|
|
|
|
channel.post({
|
|
|
|
url: '/json/users/me/status',
|
|
|
|
data: {away: false},
|
|
|
|
idempotent: true,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.set_away = function (user_id) {
|
|
|
|
away_user_ids.set(user_id, true);
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.revoke_away = function (user_id) {
|
|
|
|
away_user_ids.del(user_id);
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.is_away = function (user_id) {
|
|
|
|
return away_user_ids.has(user_id);
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.initialize = function () {
|
2019-01-21 19:06:03 +01:00
|
|
|
_.each(page_params.user_status, function (dct, user_id) {
|
|
|
|
if (dct.away) {
|
|
|
|
away_user_ids.set(user_id, true);
|
|
|
|
}
|
2018-12-19 17:11:17 +01:00
|
|
|
});
|
|
|
|
|
2019-01-21 19:06:03 +01:00
|
|
|
delete page_params.user_status;
|
2018-12-19 17:11:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return exports;
|
|
|
|
|
|
|
|
}());
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = user_status;
|
|
|
|
}
|
|
|
|
window.user_status = user_status;
|