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;