|
1 | 1 | import { HttpClient, HttpHeaders } from '@angular/common/http' |
2 | 2 | import { Injectable } from '@angular/core' |
3 | | -import { Observable, of, ReplaySubject } from 'rxjs' |
| 3 | +import { forkJoin, merge, Observable, of, ReplaySubject } from 'rxjs' |
4 | 4 | import { retry, catchError, tap, map } from 'rxjs/operators' |
5 | 5 | import { CountriesEndpoint } from 'src/app/types/record-country.endpoint' |
6 | | -import { UserRecordOptions } from 'src/app/types/record.local' |
| 6 | +import { |
| 7 | + SideBarPublicUserRecord, |
| 8 | + UserRecordOptions, |
| 9 | +} from 'src/app/types/record.local' |
7 | 10 | import { environment } from 'src/environments/environment' |
8 | 11 | import { ErrorHandlerService } from '../error-handler/error-handler.service' |
9 | 12 | import { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service' |
@@ -297,9 +300,20 @@ export class RecordCountriesService { |
297 | 300 | } |
298 | 301 | ): Observable<CountriesEndpoint> { |
299 | 302 | if (options.publicRecordId) { |
300 | | - return this._recordPublicSidebar |
301 | | - .getPublicRecordSideBar(options) |
302 | | - .pipe(map((value) => value.countries)) |
| 303 | + return forkJoin([ |
| 304 | + this._recordPublicSidebar.getPublicRecordSideBar(options), |
| 305 | + this.getCountryCodes(), |
| 306 | + ]).pipe( |
| 307 | + map((value) => { |
| 308 | + const countries = value[0].countries |
| 309 | + const countryCodes = value[1] |
| 310 | + countries.addresses.forEach((country) => { |
| 311 | + //Override backend country name translations |
| 312 | + country.countryName = countryCodes[country.iso2Country.value] || '' |
| 313 | + }) |
| 314 | + return countries |
| 315 | + }) |
| 316 | + ) |
303 | 317 | } |
304 | 318 |
|
305 | 319 | if (!this.$addresses) { |
|
0 commit comments