[DURACOM-191] Fix error on home when coar is not enabled

This commit is contained in:
Giuseppe Digilio
2024-03-08 19:14:03 +01:00
parent ae436fbd5f
commit f90880bbac
2 changed files with 13 additions and 12 deletions

View File

@@ -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<string[]> {
return this.configService.findByPropertyName('ldn.notify.inbox').pipe(
getFirstSucceededRemoteData(),
getRemoteDataPayload(),
map((response: ConfigurationProperty) => {
return response.values;
})
getFirstCompletedRemoteData(),
map((responseRD: RemoteData<ConfigurationProperty>) => responseRD.hasSucceeded ? responseRD.payload.values : [])
);
}

View File

@@ -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);
}
});