add 3 retries for language file fetch (#3859)

This commit is contained in:
Denys Vuika
2018-10-04 14:35:16 +01:00
committed by Eugenio Romano
parent 67785cba54
commit ca1505f3c1

View File

@@ -22,7 +22,7 @@ import { TranslateLoader } from '@ngx-translate/core';
import { Observable, forkJoin, throwError } from 'rxjs'; import { Observable, forkJoin, throwError } from 'rxjs';
import { ComponentTranslationModel } from '../models/component.model'; import { ComponentTranslationModel } from '../models/component.model';
import { ObjectUtils } from '../utils/object-utils'; import { ObjectUtils } from '../utils/object-utils';
import { map, catchError } from 'rxjs/operators'; import { map, catchError, retry } from 'rxjs/operators';
@Injectable() @Injectable()
export class TranslateLoaderService implements TranslateLoader { export class TranslateLoaderService implements TranslateLoader {
@@ -48,8 +48,8 @@ export class TranslateLoaderService implements TranslateLoader {
return this.providers.find(x => x.name === name) ? true : false; return this.providers.find(x => x.name === name) ? true : false;
} }
getComponentToFetch(lang: string) { getComponentToFetch(lang: string): Array<Observable<any>> {
let observableBatch = []; const observableBatch = [];
if (!this.queue[lang]) { if (!this.queue[lang]) {
this.queue[lang] = []; this.queue[lang] = [];
} }
@@ -64,6 +64,7 @@ export class TranslateLoaderService implements TranslateLoader {
map((res: Response) => { map((res: Response) => {
component.json[lang] = res; component.json[lang] = res;
}), }),
retry(3),
catchError(() => throwError(`Error loading ${translationUrl}`)) catchError(() => throwError(`Error loading ${translationUrl}`))
) )
); );