mirror of https://github.com/zulip/zulip.git
50 lines
976 B
JavaScript
50 lines
976 B
JavaScript
|
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 () {
|
||
|
_.each(page_params.away_user_ids, function (user_id) {
|
||
|
away_user_ids.set(user_id, true);
|
||
|
});
|
||
|
|
||
|
delete page_params.away_user_ids;
|
||
|
};
|
||
|
|
||
|
return exports;
|
||
|
|
||
|
}());
|
||
|
if (typeof module !== 'undefined') {
|
||
|
module.exports = user_status;
|
||
|
}
|
||
|
window.user_status = user_status;
|