activity: Refactor logic for sending active status.

This is a preparatory refactor for extending this logic to interact
with the desktop app as well.
This commit is contained in:
Tim Abbott
2019-06-28 17:55:26 -07:00
parent 793524618b
commit e59a49ade5

View File

@@ -262,15 +262,25 @@ exports.update_huddles = function () {
}; };
function send_presence_to_server(want_redraw) { function send_presence_to_server(want_redraw) {
var status;
if (reload_state.is_in_progress()) { if (reload_state.is_in_progress()) {
blueslip.log("Skipping querying presence because reload in progress"); blueslip.log("Skipping querying presence because reload in progress");
return; return;
} }
if (exports.client_is_active) {
status = exports.ACTIVE;
} else {
status = exports.IDLE;
}
channel.post({ channel.post({
url: '/json/users/me/presence', url: '/json/users/me/presence',
data: {status: exports.client_is_active ? exports.ACTIVE : exports.IDLE, data: {
status: status,
ping_only: !want_redraw, ping_only: !want_redraw,
new_user_input: exports.new_user_input}, new_user_input: exports.new_user_input,
},
idempotent: true, idempotent: true,
success: function (data) { success: function (data) {