Fixed multiple add path of same single component

This commit is contained in:
mauriziovitale84
2016-05-23 12:23:35 +01:00
parent 5c10919c8e
commit b95edb4ccf
2 changed files with 10 additions and 4 deletions

View File

@@ -34,11 +34,15 @@ export class AlfrescoTranslationLoader implements TranslateLoader {
this._componentList.push(name);
}
getTranslation(lang: string): Observable<any> {
existComponent(name: string) {
return this._componentList.indexOf(name) >= 0;
}
getTranslation(lang: string): Observable<any> {
let self = this;
let observableBatch = [];
this._componentList.forEach((component) => {
observableBatch.push(this.http.get(`${component}/${this.prefix}/${lang}${this.suffix}`)
observableBatch.push(this.http.get(`${component}/${self.prefix}/${lang}${self.suffix}`)
.map((res: Response) => res.json()));
});

View File

@@ -108,8 +108,10 @@ export class AlfrescoTranslationService {
}
addComponent(name: string) {
this.currentLoader.addComponentList(name);
this.getTranslation(this.userLang);
if (!this.currentLoader.existComponent(name)) {
this.currentLoader.addComponentList(name);
this.getTranslation(this.userLang);
}
}
/**