diff --git a/src/app/services/http/http.service.ts b/src/app/services/http/http.service.ts index d99733819768f37ca84de58164ca27253acf517e..6aea6fb802bccf68aa66bb13cf0b7a6d297e70db 100644 --- a/src/app/services/http/http.service.ts +++ b/src/app/services/http/http.service.ts @@ -27,17 +27,16 @@ export class HttpService { public httpGetRequest(protocol: string, host: string, port: number, path: string, processDataCallback: (s: string) => void, errorCallback?: (err: any) => void, - headers?: StringMap): Promise<Response> { - let resp: Observable<Response> = this.httpGetRequestResponse(protocol, host, port, path, headers); + headers?: StringMap): Promise<any> { - resp.map(res => res.text()) - .subscribe( - data => processDataCallback(data), - err => { if (errorCallback) errorCallback(err) }, - // () => console.log('Random Quote Complete') - ); - - return resp.toPromise(); + const prom = this.httpGetRequest2(protocol, host, port, path); + prom.then(data => { + processDataCallback(data); + }).catch(err => { + if (errorCallback) + errorCallback(err) + }); + return prom; } /** diff --git a/src/app/services/internationalisation/internationalisation.service.ts b/src/app/services/internationalisation/internationalisation.service.ts index dcdc33e134cfd15658994b6daead4c27ee5bdc65..09194cdd504e49a320d8a2b1aad831d8ba7823b9 100644 --- a/src/app/services/internationalisation/internationalisation.service.ts +++ b/src/app/services/internationalisation/internationalisation.service.ts @@ -99,10 +99,15 @@ export class InternationalisationService extends Observable { this._currLang = this.getLanguageFromCode(lng); } - let prom = this.httpGetMessages(); - prom.then((res) => { - this.notifyObservers(undefined); - }) + if (this._currLang.code !== oldLang) { + this._Messages = undefined; + const prom = this.httpGetMessages(); + + const is: InternationalisationService = this; + prom.then((res) => { + is.notifyObservers(undefined); + }) + } } private httpGetMessages(): Promise<Response> {