diff --git a/js/publicshareauth.js b/js/publicshareauth.js index cb651c5d946..c1f320258ef 100644 --- a/js/publicshareauth.js +++ b/js/publicshareauth.js @@ -208,7 +208,16 @@ }; OCA.SpreedMe.app = new OCA.Talk.Application(); - OCA.SpreedMe.app.start(); - OCA.Talk.PublicShareAuth.init(); + OCA.SpreedMe.app.on('start', function() { + OCA.Talk.PublicShareAuth.init(); + }); + + // Unlike in the regular Talk app when Talk is embedded the signaling + // settings are not initially included in the HTML, so they need to be + // explicitly loaded before starting the app. + OCA.Talk.Signaling.loadSettings().then(function() { + OCA.SpreedMe.app.start(); + }); + })(OCA); diff --git a/js/signaling.js b/js/signaling.js index 27377c8da59..816bb4fd73a 100644 --- a/js/signaling.js +++ b/js/signaling.js @@ -8,6 +8,47 @@ Internal: {}, Standalone: {}, + /** + * Loads the signaling settings. + * + * The signaling settings are set in the DOM element in which + * "createConnection" expects to find them; if the DOM element already + * exists it is assumed that the settings are already loaded. + * + * @return Deferred a Deferred object that will be resolved once the + * settings are loaded. + */ + loadSettings: function() { + var deferred = $.Deferred(); + + if ($('#app #signaling-settings').length > 0) { + deferred.resolve(); + + return deferred.promise(); + } + + if ($('#app').length === 0) { + $('body').append('
'); + } + $('#app').append(''); + + $.ajax({ + url: OC.linkToOCS('apps/spreed/api/v1/signaling', 2) + 'settings', + type: 'GET', + dataType: 'json', + success: function (result) { + $('#app #signaling-settings').text(JSON.stringify(result.ocs.data)); + + deferred.resolve(); + }, + error: function (xhr, textStatus, errorThrown) { + deferred.reject(xhr, textStatus, errorThrown); + } + }); + + return deferred.promise(); + }, + createConnection: function() { var settings = $("#app #signaling-settings").text(); if (settings) { diff --git a/lib/PublicShareAuth/TemplateLoader.php b/lib/PublicShareAuth/TemplateLoader.php index e50db4de0c4..8d187dcb682 100644 --- a/lib/PublicShareAuth/TemplateLoader.php +++ b/lib/PublicShareAuth/TemplateLoader.php @@ -103,7 +103,6 @@ public function loadRequestPasswordByTalkUi(IShare $share) { Util::addScript('spreed', 'signaling'); Util::addScript('spreed', 'connection'); Util::addScript('spreed', 'app'); - Util::addScript('spreed', 'init'); Util::addScript('spreed', 'publicshareauth'); }