55 *
66 * http://www.dspace.org/license/
77 */
8- import { Injectable } from '@angular/core' ;
8+ import { isPlatformBrowser } from '@angular/common' ;
9+ import {
10+ Inject ,
11+ Injectable ,
12+ PLATFORM_ID ,
13+ } from '@angular/core' ;
914import { AuthorizationDataService } from '@dspace/core/data/feature-authorization/authorization-data.service' ;
1015import { FeatureID } from '@dspace/core/data/feature-authorization/feature-id' ;
1116import { DSpaceObject } from '@dspace/core/shared/dspace-object.model' ;
@@ -23,17 +28,17 @@ import {
2328 startWith ,
2429 switchMap ,
2530} from 'rxjs/operators' ;
26- import { AuthService } from 'src/app /core/auth/auth.service' ;
31+ import { AuthService } from '@dspace /core/auth/auth.service' ;
2732
2833import { SubscriptionModalComponent } from '../../subscriptions/subscription-modal/subscription-modal.component' ;
29- import { SubscriptionsDataService } from '../../subscriptions /subscriptions-data.service' ;
34+ import { SubscriptionsDataService } from '@dspace/core/data /subscriptions-data.service' ;
3035import { OnClickMenuItemModel } from '../menu-item/models/onclick.model' ;
3136import { MenuItemType } from '../menu-item-type.model' ;
3237import { PartialMenuSection } from '../menu-provider.model' ;
3338import { DSpaceObjectPageMenuProvider } from './helper-providers/dso.menu' ;
3439
3540/**
36- * Menu provider to create the "Subscribe" option in the DSO edit menu and "Manage subscription"
41+ * Menu provider to create the "Subscribe" option in the DSO edit menu
3742 */
3843@Injectable ( )
3944export class SubscribeMenuProvider extends DSpaceObjectPageMenuProvider {
@@ -45,11 +50,15 @@ export class SubscribeMenuProvider extends DSpaceObjectPageMenuProvider {
4550 protected subscriptionService : SubscriptionsDataService ,
4651 protected modalService : NgbModal ,
4752 protected translateService : TranslateService ,
53+ @Inject ( PLATFORM_ID ) private platformId : unknown ,
4854 ) {
4955 super ( ) ;
5056 }
5157
5258 public getSectionsForContext ( dso : DSpaceObject ) : Observable < PartialMenuSection [ ] > {
59+ if ( ! isPlatformBrowser ( this . platformId ) ) {
60+ return of ( [ ] ) ;
61+ }
5362 const realSections$ = this . refresh$ . pipe (
5463 startWith ( undefined ) ,
5564 switchMap ( ( ) =>
@@ -70,9 +79,7 @@ export class SubscribeMenuProvider extends DSpaceObjectPageMenuProvider {
7079 return this . subscriptionService . getSubscriptionsByPersonDSO ( user . id , dso . uuid ) . pipe (
7180 map ( ( rd ) => {
7281 const subscription = rd . payload ?. page ?. [ 0 ] ;
73- const key = subscription
74- ? 'subscriptions.manage'
75- : 'subscriptions.tooltip' ;
82+ const key = subscription ? 'subscriptions.manage' : 'subscriptions.tooltip' ;
7683 return [
7784 {
7885 visible : true ,
0 commit comments