Skip to content

Commit

Permalink
fix(profile): Load Profile Effect
Browse files Browse the repository at this point in the history
* revised loadProfile NgRx effect to handle errors on a per-request basis and still get results for the successful requests.
  • Loading branch information
faizanalibugti committed Dec 31, 2023
1 parent 5bc3442 commit 074a623
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
54 changes: 46 additions & 8 deletions apps/filmpire/src/app/+state/profile/profile.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,54 @@ export class ProfileEffects {
filter(({ sessionId }) => !!sessionId),
concatMap(({ user, sessionId }) =>
forkJoin({
favoriteMovies: this.accountHttp.getFavoriteMovies(
user.id,
sessionId
favoriteMovies: this.accountHttp
.getFavoriteMovies(user.id, sessionId)
.pipe(
catchError((error) => {
// Handle error for getFavoriteMovies
return of({
page: 0,
total_pages: 0,
total_results: 0,
results: [],
});
})
),
favoriteTV: this.accountHttp.getFavouriteTV(user.id, sessionId).pipe(
catchError((error) => {
// Handle error for getFavoriteMovies
return of({
page: 0,
total_pages: 0,
total_results: 0,
results: [],
});
})
),
favoriteTV: this.accountHttp.getFavouriteTV(user.id, sessionId),
watchListMovies: this.accountHttp.getWatchListMovies(
user.id,
sessionId
watchListMovies: this.accountHttp
.getWatchListMovies(user.id, sessionId)
.pipe(
catchError((error) => {
// Handle error for getFavoriteMovies
return of({
page: 0,
total_pages: 0,
total_results: 0,
results: [],
});
})
),
watchListTV: this.accountHttp.getWatchListTV(user.id, sessionId).pipe(
catchError((error) => {
// Handle error for getFavoriteMovies
return of({
page: 0,
total_pages: 0,
total_results: 0,
results: [],
});
})
),
watchListTV: this.accountHttp.getWatchListTV(user.id, sessionId),
}).pipe(
map((profileData: ProfileData) =>
ProfileActions.profileApiActions.loadProfileSuccess({
Expand Down
1 change: 1 addition & 0 deletions apps/filmpire/src/app/account/account.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,5 @@ <h2 class="mb-10 text-3xl font-semibold dark:text-white">
No items to show. Please add a media to either favorite or watchlist for the
item to appear here
</p>
<br/>
</ng-template>

0 comments on commit 074a623

Please sign in to comment.