# HG changeset patch # User Ludovic Chabant # Date 1507133311 25200 # Node ID cebeedfa034f68efeab67461c1043793b230278f # Parent 41db689d36b6bf7478f701ddee25027f6694cb15 serve: Don't start the admin panel SSE until the window is ready. diff -r 41db689d36b6 -r cebeedfa034f piecrust/admin/assets/js/foodtruck.js --- a/piecrust/admin/assets/js/foodtruck.js Sun Oct 01 20:38:43 2017 -0700 +++ b/piecrust/admin/assets/js/foodtruck.js Wed Oct 04 09:08:31 2017 -0700 @@ -26,6 +26,16 @@ closePublogBtn.on('click', function() { publogEl.fadeOut(200); }); + + if (!!window.EventSource) { + // TODO: this only works when the Foodtruck blueprint is added under `/pc-admin`. + var source = new EventSource('/pc-admin/publish-log'); + source.onerror = function(e) { + console.log("Error with SSE, closing.", e); + source.close(); + }; + source.addEventListener('message', onPublishEvent); + } }); var onPublishEvent = function(e) { @@ -55,14 +65,3 @@ containerEl.append(msgEl); }; -if (!!window.EventSource) { - // TODO: this only works when the Foodtruck blueprint is added under `/pc-admin`. - var source = new EventSource('/pc-admin/publish-log'); - source.onerror = function(e) { - console.log("Error with SSE, closing.", e); - source.close(); - }; - source.addEventListener('message', onPublishEvent); -} - -