From 74df38f94fe92f04036e6bdc12a05ee3b733e033 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 5 Oct 2016 11:19:18 +0200 Subject: [PATCH] Fix race conditions that could prevent applications from being loaded --- customize.dist/main.js | 20 ++++++++++++-------- www/common/cryptpad-common.js | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/customize.dist/main.js b/customize.dist/main.js index 306db9786..2622eef1b 100644 --- a/customize.dist/main.js +++ b/customize.dist/main.js @@ -12,9 +12,6 @@ define([ Cryptpad: Cryptpad, }; - DecorateToolbar.main($('#bottom-bar')); - Cryptpad.styleAlerts(); - var padTypes = { '/pad/': Messages.type.pad, '/code/': Messages.type.code, @@ -22,9 +19,9 @@ define([ '/slide/': Messages.type.slide, }; - var $table = $('table.scroll'); - var $tbody = $table.find('tbody'); - var $tryit = $('#tryit'); + var $table; + var $tbody; + var $tryit; var now = new Date(); var hasRecent = false; @@ -138,11 +135,18 @@ define([ }); }; - displayCreateButtons(); Cryptpad.ready(function () { console.log("ready"); - refreshTable(); + $table = $('table.scroll'); + $tbody = $table.find('tbody'); + $tryit = $('#tryit'); + + DecorateToolbar.main($('#bottom-bar')); + Cryptpad.styleAlerts(); + + displayCreateButtons(); + refreshTable(); if (Cryptpad.store && Cryptpad.store.change) { Cryptpad.store.change(function (data) { if (data.key === 'CryptPad_RECENTPADS') { diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 58bc11244..addf3cd0c 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -557,7 +557,20 @@ define([ Store.ready(function (err, store) { common.store = env.store = store; - cb(); + $(function() { + if($('#pad-iframe').length) { + var $iframe = $('#pad-iframe'); + var iframe = $iframe[0]; + var iframeDoc = iframe.contentDocument || iframe.contentWindow.document; + if (iframeDoc.readyState === 'complete') { + cb(); + return; + } + $iframe.load(cb); + return; + } + cb(); + }); return; /* authorize(function (err, proxy) {