addEntry bug fix (entry doesn't have id)

This commit is contained in:
X4Lo committed 2024-04-02 01:17:25 +00:00
1 parent e639fb1036
commit 863f6bbf11
1 file changed
+4 -3
@@ -127,9 +127,9 @@ export class LibraryService implements OnInit {
addEntry(tmdb_id: string, is_tvserie: boolean): Observable<Entry | null> {
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<Entry | null> {
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;