From 02ae7f5c3639b6242f640d4788ae810debc573ba Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Tue, 30 Mar 2021 17:00:14 -0400 Subject: [PATCH] collab_client: Always run deferred actions on connect --- src/static/js/broadcast.js | 1 - src/static/js/collab_client.js | 10 ++++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/static/js/broadcast.js b/src/static/js/broadcast.js index 909b6a085..817b2f4dd 100644 --- a/src/static/js/broadcast.js +++ b/src/static/js/broadcast.js @@ -443,7 +443,6 @@ const loadBroadcastJS = (socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro }; // to start upon window load, just push a function onto this array - // window['onloadFuncts'].push(setUpSocket); // window['onloadFuncts'].push(function () fireWhenAllScriptsAreLoaded.push(() => { // set up the currentDivs and DOM diff --git a/src/static/js/collab_client.js b/src/static/js/collab_client.js index 02f364690..a449b02d6 100644 --- a/src/static/js/collab_client.js +++ b/src/static/js/collab_client.js @@ -148,11 +148,6 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad) handleUserChanges(); }; - const setUpSocket = () => { - setChannelState('CONNECTED'); - doDeferredActions(); - }; - const sendMessage = (msg) => { getSocket().json.send( { @@ -362,6 +357,9 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad) case 'CONNECTING': startConnectTime = Date.now(); break; + case 'CONNECTED': + doDeferredActions(); + break; } }; @@ -502,7 +500,7 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad) editor.setBaseAttributedText(serverVars.initialAttributedText, serverVars.apool); editor.setUserChangeNotificationCallback(handleUserChanges); - setUpSocket(); + setChannelState('CONNECTED'); return self; };