@@ -6,7 +6,7 @@ import { Button } from 'primeng/button';
66import { DialogService } from 'primeng/dynamicdialog' ;
77import { Skeleton } from 'primeng/skeleton' ;
88
9- import { filter , map , of } from 'rxjs' ;
9+ import { filter , map , Observable , of } from 'rxjs' ;
1010
1111import { DatePipe , Location } from '@angular/common' ;
1212import {
@@ -19,7 +19,7 @@ import {
1919 OnDestroy ,
2020 OnInit ,
2121} from '@angular/core' ;
22- import { takeUntilDestroyed , toSignal } from '@angular/core/rxjs-interop' ;
22+ import { takeUntilDestroyed , toObservable , toSignal } from '@angular/core/rxjs-interop' ;
2323import { ActivatedRoute , Router } from '@angular/router' ;
2424
2525import { UserSelectors } from '@core/store/user' ;
@@ -46,6 +46,7 @@ import {
4646import { GetPreprintProviderById , PreprintProvidersSelectors } from '@osf/features/preprints/store/preprint-providers' ;
4747import { CreateNewVersion , PreprintStepperSelectors } from '@osf/features/preprints/store/preprint-stepper' ;
4848import { IS_MEDIUM , pathJoin } from '@osf/shared/helpers' ;
49+ import { DataciteTrackerComponent } from '@shared/components/datacite-tracker/datacite-tracker.component' ;
4950import { ReviewPermissions , UserPermissions } from '@shared/enums' ;
5051import { MetaTagsService } from '@shared/services' ;
5152import { ContributorsSelectors } from '@shared/stores' ;
@@ -75,7 +76,7 @@ import { environment } from 'src/environments/environment';
7576 providers : [ DialogService , DatePipe ] ,
7677 changeDetection : ChangeDetectionStrategy . OnPush ,
7778} )
78- export class PreprintDetailsComponent implements OnInit , OnDestroy {
79+ export class PreprintDetailsComponent extends DataciteTrackerComponent implements OnInit , OnDestroy {
7980 @HostBinding ( 'class' ) classes = 'flex-1 flex flex-column w-full' ;
8081
8182 private readonly router = inject ( Router ) ;
@@ -105,6 +106,7 @@ export class PreprintDetailsComponent implements OnInit, OnDestroy {
105106 preprintProvider = select ( PreprintProvidersSelectors . getPreprintProviderDetails ( this . providerId ( ) ) ) ;
106107 isPreprintProviderLoading = select ( PreprintProvidersSelectors . isPreprintProviderDetailsLoading ) ;
107108 preprint = select ( PreprintSelectors . getPreprint ) ;
109+ preprint$ = toObservable ( select ( PreprintSelectors . getPreprint ) ) ;
108110 isPreprintLoading = select ( PreprintSelectors . isPreprintLoading ) ;
109111 contributors = select ( ContributorsSelectors . getContributors ) ;
110112 areContributorsLoading = select ( ContributorsSelectors . isContributorsLoading ) ;
@@ -281,12 +283,19 @@ export class PreprintDetailsComponent implements OnInit, OnDestroy {
281283 this . fetchPreprint ( this . preprintId ( ) ) ;
282284 } ,
283285 } ) ;
286+ this . setupDataciteViewTrackerEffect ( ) . subscribe ( ) ;
284287 }
285288
286289 ngOnDestroy ( ) {
287290 this . actions . resetState ( ) ;
288291 }
289292
293+ protected getDoi ( ) : Observable < string | null > {
294+ return this . preprint$ . pipe (
295+ filter ( ( project ) => project != null ) ,
296+ map ( ( project ) => project ?. identifiers ?. find ( ( item ) => item . category == 'doi' ) ?. value ?? null )
297+ ) ;
298+ }
290299 fetchPreprintVersion ( preprintVersionId : string ) {
291300 const currentUrl = this . router . url ;
292301 const newUrl = currentUrl . replace ( / [ ^ / ] + $ / , preprintVersionId ) ;
0 commit comments