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