From 2b2cc44851e18b56c4aad147265f81f2ca3dd7d6 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Tue, 10 Sep 2024 19:02:29 +0100 Subject: [PATCH] Front: minor change in tmdb service --- frontend/src/app/core/services/tmdb.service.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/core/services/tmdb.service.ts b/frontend/src/app/core/services/tmdb.service.ts index 3b48cbe..8eef5d8 100644 --- a/frontend/src/app/core/services/tmdb.service.ts +++ b/frontend/src/app/core/services/tmdb.service.ts @@ -5,6 +5,7 @@ import { Entry } from '../../shared/models/entry.model'; import { EntryId } from '../../shared/models/entryId.model'; import { EntryRating } from '../../shared/models/entryRating.model'; import { environment } from '../../../environments/environment.prod'; +import { LibraryService } from './library.service'; @Injectable({ providedIn: 'root', @@ -12,7 +13,10 @@ import { environment } from '../../../environments/environment.prod'; export class TmdbService { cach: Record = {}; - constructor(private http: HttpClient) {} + constructor( + private http: HttpClient, + private libraryService: LibraryService + ) {} // private apiUrl = environment.apiBaseUrl; private tmdb_apiUrl = environment.TMDB_API_URL; @@ -101,6 +105,14 @@ export class TmdbService { entry.media_type === 'tv' || entry.media_type === 'movie' ), map((entry: any) => this.adaptMovieToEntry(entry)), + switchMap((entry: any) => + this.libraryService.isInLibrary(entry.entryId.tmdb_id).pipe( + map((inLibrary) => { + // console.log(inLibrary); + return inLibrary ? inLibrary : entry; + }) + ) + ), toArray(), map((entries) => ({ entries: entries,