Commits

Giuseppe Digilio authored 472fa1c4734
Fix issue with REFRESH_USER_SUGGESTIONS action
No tags

src/app/notifications/suggestion-targets/suggestion-targets.effects.ts

Modified
12 12 map,
13 13 switchMap,
14 14 tap,
15 15 } from 'rxjs/operators';
16 16
17 17 import {
18 18 AuthActionTypes,
19 19 RetrieveAuthenticatedEpersonSuccessAction,
20 20 } from '../../core/auth/auth.actions';
21 21 import { PaginatedList } from '../../core/data/paginated-list.model';
22 -import { EPerson } from '../../core/eperson/models/eperson.model';
23 22 import { SuggestionTarget } from '../../core/notifications/suggestions/models/suggestion-target.model';
24 23 import { NotificationsService } from '../../shared/notifications/notifications.service';
25 24 import { SuggestionsService } from '../suggestions.service';
26 25 import {
27 26 AddTargetAction,
28 27 AddUserSuggestionsAction,
29 28 RefreshUserSuggestionsErrorAction,
30 29 RetrieveTargetsBySourceAction,
31 30 RetrieveTargetsBySourceErrorAction,
32 31 SuggestionTargetActionTypes,
82 81 map((suggestionTargets: SuggestionTarget[]) => new AddUserSuggestionsAction(suggestionTargets)),
83 82 );
84 83 })));
85 84
86 85 /**
87 86 * Fetch the current user suggestion
88 87 */
89 88 refreshUserSuggestionsAction$ = createEffect(() => this.actions$.pipe(
90 89 ofType(SuggestionTargetActionTypes.REFRESH_USER_SUGGESTIONS),
91 90 switchMap(() => {
92 - return this.store$.select((state: any) => state.core.auth.user)
91 + return this.store$.select((state: any) => state.core.auth.userId)
93 92 .pipe(
94 - switchMap((user: EPerson) => {
95 - return this.suggestionsService.retrieveCurrentUserSuggestions(user.uuid)
93 + switchMap((userId: string) => {
94 + return this.suggestionsService.retrieveCurrentUserSuggestions(userId)
96 95 .pipe(
97 96 map((suggestionTargets: SuggestionTarget[]) => new AddUserSuggestionsAction(suggestionTargets)),
98 97 catchError((error: unknown) => {
99 98 if (error instanceof Error) {
100 99 console.error(error.message);
101 100 }
102 101 return of(new RefreshUserSuggestionsErrorAction());
103 102 }),
104 103 );
105 104 }),

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut