sockets: Remove redundant defering in _setup_sockjs_callbacks.

This deferment is redundant because we are already waiting for document
ready in transmit.js where we initialize this Socket object.
This commit is contained in:
Shubham Dhama
2018-06-14 21:45:55 +05:30
committed by Tim Abbott
parent 25c46e3abb
commit 6eaa54a876

View File

@@ -207,42 +207,38 @@ Socket.prototype = {
// Notify listeners that we've finished the websocket handshake // Notify listeners that we've finished the websocket handshake
$(document).trigger($.Event('websocket_postopen.zulip', {})); $(document).trigger($.Event('websocket_postopen.zulip', {}));
// We can only authenticate after the DOM has loaded because we need var request = that._make_request('auth');
// the CSRF token request.msg = {csrf_token: csrf_token,
$(function () { queue_id: page_params.queue_id,
var request = that._make_request('auth'); status_inquiries: _.keys(that._requests)};
request.msg = {csrf_token: csrf_token, request.success = function (resp) {
queue_id: page_params.queue_id, that._is_authenticated = true;
status_inquiries: _.keys(that._requests)}; that._is_reconnecting = false;
request.success = function (resp) { that._reconnect_initiation_time = null;
that._is_authenticated = true; that._connection_failures = 0;
that._is_reconnecting = false; var resend_queue = [];
that._reconnect_initiation_time = null; _.each(resp.status_inquiries, function (status, id) {
that._connection_failures = 0; if (status.status === 'complete') {
var resend_queue = []; that._process_response(id, status.response);
_.each(resp.status_inquiries, function (status, id) { } else if (status.status === 'received') {
if (status.status === 'complete') { that._update_request_state(id, 'sent');
that._process_response(id, status.response); } else if (status.status === 'not_received') {
} else if (status.status === 'received') { resend_queue.push(id);
that._update_request_state(id, 'sent'); }
} else if (status.status === 'not_received') { });
resend_queue.push(id); resend_queue.sort(that._req_id_sorter);
} _.each(resend_queue, function (id) {
}); that._resend(id);
resend_queue.sort(that._req_id_sorter); });
_.each(resend_queue, function (id) { };
that._resend(id); request.error = function (type, resp) {
}); blueslip.info("Could not authenticate with server: " + resp.msg);
}; that._connection_failures += 1;
request.error = function (type, resp) { that._try_to_reconnect({reason: 'auth_fail',
blueslip.info("Could not authenticate with server: " + resp.msg); wait_time: that._reconnect_wait_time()});
that._connection_failures += 1; };
that._try_to_reconnect({reason: 'auth_fail', that._save_request(request);
wait_time: that._reconnect_wait_time()}); that._do_send(request);
};
that._save_request(request);
that._do_send(request);
});
}; };
sockjs.onmessage = function Socket__sockjs_onmessage(event) { sockjs.onmessage = function Socket__sockjs_onmessage(event) {