mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
This commit was originally automatically generated using `tools/lint --only=eslint --fix`. It was then modified by tabbott to contain only changes to a set of files that are unlikely to result in significant merge conflicts with any open pull request, excluding about 20 files. His plan is to merge the remaining changes with more precise care, potentially involving merging parts of conflicting pull requests before running the `eslint --fix` operation. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
70 lines
1.5 KiB
JavaScript
70 lines
1.5 KiB
JavaScript
const Dict = require('./dict').Dict;
|
|
|
|
const away_user_ids = new Dict();
|
|
const user_info = new Dict();
|
|
|
|
exports.server_update = function (opts) {
|
|
channel.post({
|
|
url: '/json/users/me/status',
|
|
data: {
|
|
away: opts.away,
|
|
status_text: opts.status_text,
|
|
},
|
|
idempotent: true,
|
|
success: function () {
|
|
if (opts.success) {
|
|
opts.success();
|
|
}
|
|
},
|
|
});
|
|
};
|
|
|
|
exports.server_set_away = function () {
|
|
exports.server_update({away: true});
|
|
};
|
|
|
|
exports.server_revoke_away = function () {
|
|
exports.server_update({away: false});
|
|
};
|
|
|
|
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.get_status_text = function (user_id) {
|
|
return user_info.get(user_id);
|
|
};
|
|
|
|
exports.set_status_text = function (opts) {
|
|
if (!opts.status_text) {
|
|
user_info.del(opts.user_id);
|
|
return;
|
|
}
|
|
|
|
user_info.set(opts.user_id, opts.status_text);
|
|
};
|
|
|
|
exports.initialize = function () {
|
|
_.each(page_params.user_status, function (dct, user_id) {
|
|
if (dct.away) {
|
|
away_user_ids.set(user_id, true);
|
|
}
|
|
|
|
if (dct.status_text) {
|
|
user_info.set(user_id, dct.status_text);
|
|
}
|
|
});
|
|
|
|
delete page_params.user_status;
|
|
};
|
|
|
|
window.user_status = exports;
|