mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
59695: Refactored getFirstItemFor
This commit is contained in:
@@ -88,3 +88,12 @@ export const getBrowseDefinitionLinks = (definitionID: string) =>
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* Get the first occurrence of an object within a paginated list
|
||||
*/
|
||||
export const getFirstOccurrence = () =>
|
||||
<T extends DSpaceObject>(source: Observable<RemoteData<PaginatedList<T>>>): Observable<RemoteData<T>> =>
|
||||
source.pipe(
|
||||
map((rd) => Object.assign(rd, { payload: rd.payload.page.length > 0 ? rd.payload.page[0] : undefined }))
|
||||
);
|
||||
|
Reference in New Issue
Block a user