diff --git a/src/app/core/coar-notify/notify-info/notify-info.service.ts b/src/app/core/coar-notify/notify-info/notify-info.service.ts index a15c64237c..5be9026d14 100644 --- a/src/app/core/coar-notify/notify-info/notify-info.service.ts +++ b/src/app/core/coar-notify/notify-info/notify-info.service.ts @@ -1,10 +1,11 @@ import { Injectable } from '@angular/core'; -import { getFirstSucceededRemoteData, getRemoteDataPayload } from '../../shared/operators'; +import { getFirstCompletedRemoteData } from '../../shared/operators'; import { ConfigurationDataService } from '../../data/configuration-data.service'; import { map, Observable } from 'rxjs'; import { ConfigurationProperty } from '../../shared/configuration-property.model'; import { AuthorizationDataService } from '../../data/feature-authorization/authorization-data.service'; import { FeatureID } from '../../data/feature-authorization/feature-id'; +import { RemoteData } from '../../data/remote-data'; /** * Service to check COAR availability and LDN services information for the COAR Notify functionalities @@ -34,11 +35,8 @@ export class NotifyInfoService { */ getCoarLdnLocalInboxUrls(): Observable { return this.configService.findByPropertyName('ldn.notify.inbox').pipe( - getFirstSucceededRemoteData(), - getRemoteDataPayload(), - map((response: ConfigurationProperty) => { - return response.values; - }) + getFirstCompletedRemoteData(), + map((responseRD: RemoteData) => responseRD.hasSucceeded ? responseRD.payload.values : []) ); } diff --git a/src/app/home-page/home-page.component.ts b/src/app/home-page/home-page.component.ts index 3315898eb5..fe2ff1ed9c 100644 --- a/src/app/home-page/home-page.component.ts +++ b/src/app/home-page/home-page.component.ts @@ -6,12 +6,13 @@ import { Site } from '../core/shared/site.model'; import { environment } from '../../environments/environment'; import { TranslateModule } from '@ngx-translate/core'; import { RecentItemListComponent } from './recent-item-list/recent-item-list.component'; -import { ThemedTopLevelCommunityListComponent } from './top-level-community-list/themed-top-level-community-list.component'; +import { + ThemedTopLevelCommunityListComponent +} from './top-level-community-list/themed-top-level-community-list.component'; import { ThemedSearchFormComponent } from '../shared/search-form/themed-search-form.component'; import { ViewTrackerComponent } from '../statistics/angulartics/dspace/view-tracker.component'; -import { NgIf, AsyncPipe, NgClass } from '@angular/common'; +import { AsyncPipe, isPlatformServer, NgClass, NgIf } from '@angular/common'; import { ThemedHomeNewsComponent } from './home-news/themed-home-news.component'; -import { isPlatformServer } from '@angular/common'; import { ServerResponseService } from '../core/services/server-response.service'; import { NotifyInfoService } from '../core/coar-notify/notify-info/notify-info.service'; import { LinkDefinition, LinkHeadService } from '../core/services/link-head.service'; @@ -20,6 +21,8 @@ import { isNotEmpty } from '../shared/empty.util'; import { APP_CONFIG, AppConfig } from 'src/config/app-config.interface'; import { ConfigurationSearchPageComponent } from '../search-page/configuration-search-page.component'; import { SuggestionsPopupComponent } from '../notifications/suggestions-popup/suggestions-popup.component'; +import { EMPTY } from 'rxjs/internal/observable/empty'; + @Component({ selector: 'ds-home-page', styleUrls: ['./home-page.component.scss'], @@ -48,13 +51,13 @@ export class HomePageComponent implements OnInit, OnDestroy { // Get COAR REST API URLs from REST configuration // only if COAR configuration is enabled this.notifyInfoService.isCoarConfigEnabled().pipe( - switchMap((coarLdnEnabled: boolean) => { + switchMap((coarLdnEnabled: boolean) => coarLdnEnabled ? this.notifyInfoService.getCoarLdnLocalInboxUrls() : EMPTY /*{ if (coarLdnEnabled) { return this.notifyInfoService.getCoarLdnLocalInboxUrls(); } - }) + }*/) ).subscribe((coarRestApiUrls: string[]) => { - if (coarRestApiUrls.length > 0) { + if (coarRestApiUrls?.length > 0) { this.initPageLinks(coarRestApiUrls); } });