MOBILE-2567 siteplugins: Fix error if initResult not defined

main
Dani Palou 2018-09-03 16:45:39 +02:00
parent a0d76b9370
commit 9460133e0a
1 changed files with 12 additions and 8 deletions

View File

@ -149,15 +149,19 @@ export class CoreSitePluginsProvider {
* @return {any} An object with the data to pass to the JS.
*/
createDataForJS(initResult: any, contentResult?: any): any {
// First of all, add the data returned by the init JS (if any).
let data = this.utils.clone(initResult.jsResult || {});
if (typeof data == 'boolean') {
data = {};
}
let data;
// Now add some data returned by the init WS call.
data.INIT_TEMPLATES = this.utils.objectToKeyValueMap(initResult.templates, 'id', 'html');
data.INIT_OTHERDATA = initResult.otherdata;
if (initResult) {
// First of all, add the data returned by the init JS (if any).
data = this.utils.clone(initResult.jsResult || {});
if (typeof data == 'boolean') {
data = {};
}
// Now add some data returned by the init WS call.
data.INIT_TEMPLATES = this.utils.objectToKeyValueMap(initResult.templates, 'id', 'html');
data.INIT_OTHERDATA = initResult.otherdata;
}
if (contentResult) {
// Now add the data returned by the content WS call.