local echo: Remove buggy restart-related code.

We had code that would try to re-render locally echoed messages
that were rendered right before a browser restart.  This code
has gotten buggy over time, so we are removing it for now.

We will try to re-solve the problem as part of #5825, but
possibly with a different strategy.
This commit is contained in:
Steve Howell
2017-07-17 15:55:37 -04:00
committed by Tim Abbott
parent 9e81fc39e0
commit 92ad988144
2 changed files with 1 additions and 45 deletions

View File

@@ -4,7 +4,6 @@ var exports = {};
var waiting_for_id = {};
var waiting_for_ack = {};
var home_view_loaded = false;
function resend_message(message, row) {
message.content = message.raw_content;
@@ -234,41 +233,6 @@ $(function () {
on_failed_action('remove', abort_message);
on_failed_action('refresh', resend_message);
on_failed_action('edit', edit_failed_message);
$(document).on('home_view_loaded.zulip', function () {
home_view_loaded = true;
});
});
$(document).on('socket_loaded_requests.zulip', function (event, data) {
var msgs_to_insert = [];
var next_local_id = get_next_local_id();
_.each(data.requests, function (socket_msg) {
var msg = socket_msg.msg;
// Check for any message objects, then insert them locally
if (msg.stream === undefined || msg.local_id === undefined) {
return;
}
msg.local_id = next_local_id;
msg.queue_id = page_params.queue_id;
next_local_id = truncate_precision(next_local_id + 0.01);
msgs_to_insert.push(msg);
});
function echo_pending_messages() {
_.each(msgs_to_insert, function (msg) {
insert_local_message(msg, msg.local_id);
});
}
if (home_view_loaded) {
echo_pending_messages();
} else {
$(document).on('home_view_loaded.zulip', function () {
echo_pending_messages();
});
}
});
return exports;

View File

@@ -32,12 +32,6 @@ function Socket(url) {
that._try_to_reconnect({reason: 'unsuspend'});
});
// Notify any listeners that we've restored these requests from localstorage
// Listeners may mutate request objects in this list to affect re-send behaviour
if (Object.keys(this._requests).length !== 0) {
$(document).trigger('socket_loaded_requests.zulip', {requests: this._requests});
}
this._supported_protocols = ['websocket', 'xdr-streaming', 'xhr-streaming',
'xdr-polling', 'xhr-polling', 'jsonp-polling'];
if (page_params.test_suite) {
@@ -69,9 +63,7 @@ Socket.prototype = {
// browser restarts if a restart takes place before a message
// is successfully transmitted.
// If that is the case, the success/error callbacks will not
// be automatically called. They can be re-added by modifying
// the loaded-from-localStorage request in the payload of
// the socket_loaded_requests.zulip event.
// be automatically called.
send: function Socket__send(msg, success, error) {
var request = this._make_request('request');
request.msg = msg;