Skip to content

Commit

Permalink
Merge pull request #1297 from nextcloud/backport/1277/signaling-setti…
Browse files Browse the repository at this point in the history
…ngs-not-loaded-when-requesting-the-password-by-talk

[stable14] Signaling settings not loaded when requesting the password by talk
  • Loading branch information
nickvergessen authored Nov 13, 2018
2 parents c68a5e1 + 1f8d70d commit 07a8873
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
13 changes: 11 additions & 2 deletions js/publicshareauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
41 changes: 41 additions & 0 deletions js/signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<div id="app"></div>');
}
$('#app').append('<script type="text/json" id="signaling-settings"></script>');

$.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) {
Expand Down
1 change: 0 additions & 1 deletion lib/PublicShareAuth/TemplateLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down

0 comments on commit 07a8873

Please sign in to comment.