Skip to content

Commit

Permalink
refactor(platform): remove isApiCompatible
Browse files Browse the repository at this point in the history
as the error is thrown from getApiVersion()
  • Loading branch information
fgravin committed Dec 2, 2023
1 parent d51d1ab commit 17b3c52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
21 changes: 8 additions & 13 deletions libs/api/repository/src/lib/gn4/platform/gn4-platform.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Gn4PlatformService implements PlatformServiceInterface {
private readonly type = 'GeoNetwork'
private me$: Observable<UserModel>
private users$: Observable<UserModel[]>
isAnonymous$: Observable<boolean>
private isAnonymous$: Observable<boolean>

private settings$ = of(true).pipe(
switchMap(() => this.siteApiService.getSiteOrPortalDescription()),
Expand All @@ -26,18 +26,16 @@ export class Gn4PlatformService implements PlatformServiceInterface {

private readonly apiVersion$ = this.settings$.pipe(
map((info) => info['system/platform/version'] as string),
tap((version) => {
if (ltr(version, minApiVersion)) {
throw new Error(
`Gn4 API version is not compatible.\nMinimum: ${minApiVersion}\nYour version: ${version}`
)
}
}),
shareReplay(1)
)

private readonly isApiCompatible$ = this.apiVersion$.pipe(
tap(
(version) =>
version < minApiVersion &&
console.warn(`The GeoNetwork Api version is too low ${version}`)
),
map((version) => version >= minApiVersion)
)

constructor(
private siteApiService: SiteApiService,
private meApi: MeApiService,
Expand All @@ -62,9 +60,6 @@ export class Gn4PlatformService implements PlatformServiceInterface {
getApiVersion(): Observable<string> {
return this.apiVersion$
}
isApiCompatible(): Observable<boolean> {
return this.isApiCompatible$
}

getMe(): Observable<UserModel> {
return this.me$
Expand Down
1 change: 0 additions & 1 deletion libs/common/domain/src/lib/platform.service.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Organization } from './model/record/organization.model'
export abstract class PlatformServiceInterface {
abstract getType(): string
abstract getApiVersion(): Observable<string>
abstract isApiCompatible(): Observable<boolean>

abstract getMe(): Observable<UserModel>
abstract isAnonymous(): Observable<boolean>
Expand Down

0 comments on commit 17b3c52

Please sign in to comment.