Removed circ dependency after merge with main

This commit is contained in:
lotte
2022-04-20 15:34:32 +02:00
parent 014fe1b733
commit d364804c42
3 changed files with 27 additions and 23 deletions

View File

@@ -20,8 +20,7 @@ import { DSpaceObject } from '../shared/dspace-object.model';
import { Item } from '../shared/item.model';
import {
getFirstCompletedRemoteData,
getFirstSucceededRemoteDataPayload,
getDownloadableBitstream
getFirstSucceededRemoteDataPayload
} from '../shared/operators';
import { RootDataService } from '../data/root-data.service';
import { getBitstreamDownloadRoute } from '../../app-routing-paths';
@@ -37,6 +36,7 @@ import { AddMetaTagAction, ClearMetaTagAction } from './meta-tag.actions';
import { coreSelector } from '../core.selectors';
import { CoreState } from '../core-state.model';
import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service';
import { getDownloadableBitstream } from '../shared/bitstream.operators';
/**
* The base selector function to select the metaTag section in the store

View File

@@ -0,0 +1,24 @@
import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service';
import { Observable, of as observableOf } from 'rxjs';
import { Bitstream } from './bitstream.model';
import { map, switchMap } from 'rxjs/operators';
import { hasValue } from '../../shared/empty.util';
import { FeatureID } from '../data/feature-authorization/feature-id';
/**
* Operator to check if the given bitstream is downloadable
*/
export const getDownloadableBitstream = (authService: AuthorizationDataService) =>
(source: Observable<Bitstream>): Observable<Bitstream | null> =>
source.pipe(
switchMap((bit: Bitstream) => {
if (hasValue(bit)) {
return authService.isAuthorized(FeatureID.CanDownload, bit.self).pipe(
map((canDownload: boolean) => {
return canDownload ? bit : null;
}));
} else {
return observableOf(null);
}
})
);

View File

@@ -1,4 +1,4 @@
import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs';
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { debounceTime, filter, find, map, switchMap, take, takeWhile } from 'rxjs/operators';
import { hasNoValue, hasValue, hasValueOperator, isNotEmpty } from '../../shared/empty.util';
import { SearchResult } from '../../shared/search/models/search-result.model';
@@ -9,9 +9,6 @@ import { MetadataSchema } from '../metadata/metadata-schema.model';
import { BrowseDefinition } from './browse-definition.model';
import { DSpaceObject } from './dspace-object.model';
import { InjectionToken } from '@angular/core';
import { Bitstream } from './bitstream.model';
import { FeatureID } from '../data/feature-authorization/feature-id';
import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service';
export const DEBOUNCE_TIME_OPERATOR = new InjectionToken<<T>(dueTime: number) => (source: Observable<T>) => Observable<T>>('debounceTime', {
providedIn: 'root',
@@ -225,20 +222,3 @@ export const metadataFieldsToString = () =>
})
);
/**
* Operator to check if the given bitstream is downloadable
*/
export const getDownloadableBitstream = (authService: AuthorizationDataService) =>
(source: Observable<Bitstream>): Observable<Bitstream | null> =>
source.pipe(
switchMap((bit: Bitstream) => {
if (hasValue(bit)) {
return authService.isAuthorized(FeatureID.CanDownload, bit.self).pipe(
map((canDownload: boolean) => {
return canDownload ? bit : null;
}));
} else {
return observableOf(null);
}
})
);