From 863f6bbf11a0e20791bc1a38bcfd9e67717b1ac9 Mon Sep 17 00:00:00 2001 From: Mohammed Abad Date: Tue, 2 Apr 2024 01:17:25 +0000 Subject: [PATCH] addEntry bug fix (entry doesn't have id) --- frontend/src/app/core/services/library.service.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/core/services/library.service.ts b/frontend/src/app/core/services/library.service.ts index 2f4bf09..f81813c 100644 --- a/frontend/src/app/core/services/library.service.ts +++ b/frontend/src/app/core/services/library.service.ts @@ -127,9 +127,9 @@ export class LibraryService implements OnInit { addEntry(tmdb_id: string, is_tvserie: boolean): Observable { return this.getAllEntries().pipe( switchMap((entries) => { - const existingEntry = entries.find( - (entry) => entry.entryId.imdb_id === tmdb_id - ); + const existingEntry = entries.find((entry) => { + if (entry.entryId?.tmdb_id) entry.entryId.tmdb_id == tmdb_id; + }); if (existingEntry) { return of(existingEntry); } else { @@ -150,6 +150,7 @@ export class LibraryService implements OnInit { isInLibrary(tmdb_id: string): Observable { return this.getAllEntries().pipe( switchMap((entries) => { + if (entries.length == 0) return of(null); const existingEntry = entries.find((entry) => { // console.log(entry.entryId.tmdb_id, tmdb_id); return entry.entryId.tmdb_id == tmdb_id;