MOBILE-2838 site: Index functions by name to speed up wsAvailable
parent
9134933217
commit
732e3fccb6
|
@ -217,6 +217,7 @@ export class CoreSite {
|
||||||
this.wsProvider = injector.get(CoreWSProvider);
|
this.wsProvider = injector.get(CoreWSProvider);
|
||||||
|
|
||||||
this.logger = logger.getInstance('CoreWSProvider');
|
this.logger = logger.getInstance('CoreWSProvider');
|
||||||
|
this.setInfo(infos);
|
||||||
this.calculateOfflineDisabled();
|
this.calculateOfflineDisabled();
|
||||||
|
|
||||||
if (this.id) {
|
if (this.id) {
|
||||||
|
@ -349,6 +350,14 @@ export class CoreSite {
|
||||||
*/
|
*/
|
||||||
setInfo(infos: any): void {
|
setInfo(infos: any): void {
|
||||||
this.infos = infos;
|
this.infos = infos;
|
||||||
|
|
||||||
|
// Index function by name to speed up wsAvailable method.
|
||||||
|
if (infos && infos.functions) {
|
||||||
|
infos.functionsByName = {};
|
||||||
|
infos.functions.forEach((func) => {
|
||||||
|
infos.functionsByName[func.name] = func;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -711,11 +720,8 @@ export class CoreSite {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < this.infos.functions.length; i++) {
|
if (this.infos.functionsByName[method]) {
|
||||||
const func = this.infos.functions[i];
|
return true;
|
||||||
if (func.name == method) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's try again with the compatibility prefix.
|
// Let's try again with the compatibility prefix.
|
||||||
|
|
Loading…
Reference in New Issue