@@ -11,7 +11,7 @@ import { hasValue, isNotEmpty } from '../shared/empty.util';
1111import { ResearcherProfile } from '../core/profile/model/researcher-profile.model' ;
1212import {
1313 getAllSucceededRemoteDataPayload ,
14- getFinishedRemoteData ,
14+ getFinishedRemoteData , getFirstCompletedRemoteData ,
1515 getFirstSucceededRemoteDataPayload ,
1616 getFirstSucceededRemoteListPayload
1717} from '../core/shared/operators' ;
@@ -155,10 +155,10 @@ export class SuggestionsService {
155155 */
156156 public retrieveCurrentUserSuggestions ( userUuid : string ) : Observable < SuggestionTarget [ ] > {
157157 return this . researcherProfileService . findById ( userUuid , true ) . pipe (
158- getFirstSucceededRemoteDataPayload ( ) ,
159- mergeMap ( ( profile : ResearcherProfile ) => {
160- if ( isNotEmpty ( profile ) ) {
161- return this . researcherProfileService . findRelatedItemId ( profile ) . pipe (
158+ getFirstCompletedRemoteData ( ) ,
159+ mergeMap ( ( profile : RemoteData < ResearcherProfile > ) => {
160+ if ( isNotEmpty ( profile ) && profile . hasSucceeded && isNotEmpty ( profile . payload ) ) {
161+ return this . researcherProfileService . findRelatedItemId ( profile . payload ) . pipe (
162162 mergeMap ( ( itemId : string ) => {
163163 return this . suggestionsDataService . getTargetsByUser ( itemId ) . pipe (
164164 getFirstSucceededRemoteListPayload ( )
@@ -169,7 +169,7 @@ export class SuggestionsService {
169169 return of ( [ ] ) ;
170170 }
171171 } ) ,
172- take ( 1 )
172+ catchError ( ( ) => of ( [ ] ) )
173173 ) ;
174174 }
175175
0 commit comments