F: Fixed movie entry not showing up correctly in library page when adding a seen date to it while it is in watchlist.
This commit is contained in:
1 parent
0466082fe8
commit
b799e1cada
4 files changed
+76
-52
No files matched your search
@@ -79,25 +79,24 @@ export class LibraryService implements OnInit {
|
|||||||
const existingEntry = this.entriesSubject
|
const existingEntry = this.entriesSubject
|
||||||
.getValue()
|
.getValue()
|
||||||
.find((entry) => entry.entryId?.tmdb_id == tmdb_id);
|
.find((entry) => entry.entryId?.tmdb_id == tmdb_id);
|
||||||
if (existingEntry) {
|
|
||||||
return of(existingEntry);
|
if (existingEntry) return of(existingEntry);
|
||||||
} else {
|
|
||||||
return this.http
|
return this.http
|
||||||
.post<Entry>(`${this.backend_apiUrl}/${this.apiAction}`, {
|
.post<Entry>(`${this.backend_apiUrl}/${this.apiAction}`, {
|
||||||
tmdb_id: tmdb_id,
|
tmdb_id: tmdb_id,
|
||||||
is_tvserie: is_tvserie,
|
is_tvserie: is_tvserie,
|
||||||
|
})
|
||||||
|
.pipe(
|
||||||
|
tap((newEntry) => {
|
||||||
|
newEntry.isInLibrary = true;
|
||||||
|
|
||||||
|
const currentEntries = this.entriesSubject.getValue();
|
||||||
|
const updatedEntries = [...currentEntries, newEntry];
|
||||||
|
|
||||||
|
this.entriesSubject.next(updatedEntries);
|
||||||
})
|
})
|
||||||
.pipe(
|
);
|
||||||
tap((newEntry) => {
|
|
||||||
newEntry.isInLibrary = true;
|
|
||||||
|
|
||||||
const currentEntries = this.entriesSubject.getValue();
|
|
||||||
const updatedEntries = [...currentEntries, newEntry];
|
|
||||||
|
|
||||||
this.entriesSubject.next(updatedEntries);
|
|
||||||
}) // Add new entry to the list
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public deleteEntry(id: number): Observable<any> {
|
public deleteEntry(id: number): Observable<any> {
|
||||||
@@ -115,11 +114,13 @@ export class LibraryService implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setEntry(entry: Entry) {
|
public updateEntry(entry: Entry) {
|
||||||
const currentEntries = this.entriesSubject.getValue();
|
const currentEntries = this.entriesSubject.getValue();
|
||||||
let updatedEntries = currentEntries.filter((e) => e.id != entry.id);
|
|
||||||
|
|
||||||
updatedEntries.push(entry);
|
const updatedEntries = [
|
||||||
|
...currentEntries.filter((e) => e.id !== entry.id),
|
||||||
|
entry,
|
||||||
|
];
|
||||||
|
|
||||||
this.entriesSubject.next(updatedEntries);
|
this.entriesSubject.next(updatedEntries);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -146,7 +146,7 @@ export class AlternateEntryPageComponent implements OnInit {
|
|||||||
if (entryRatings) {
|
if (entryRatings) {
|
||||||
// TODO show notification
|
// TODO show notification
|
||||||
this.entry.entryRating = entryRatings;
|
this.entry.entryRating = entryRatings;
|
||||||
this.libraryService.setEntry(this.entry);
|
this.libraryService.updateEntry(this.entry);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
@@ -218,7 +218,7 @@ export class AlternateEntryPageComponent implements OnInit {
|
|||||||
// ? update the watchlist page
|
// ? update the watchlist page
|
||||||
if (this.entry.watchlist) {
|
if (this.entry.watchlist) {
|
||||||
this.entry.watchlist = false;
|
this.entry.watchlist = false;
|
||||||
this.libraryService.setEntry(this.entry);
|
this.libraryService.updateEntry(this.entry);
|
||||||
|
|
||||||
// this.libraryService.refetchEntries().subscribe();
|
// this.libraryService.refetchEntries().subscribe();
|
||||||
}
|
}
|
||||||
@@ -287,7 +287,7 @@ export class AlternateEntryPageComponent implements OnInit {
|
|||||||
// console.log(`Entry updated: `, entry);
|
// console.log(`Entry updated: `, entry);
|
||||||
this.entry = entry;
|
this.entry = entry;
|
||||||
this.entry.isInLibrary = true;
|
this.entry.isInLibrary = true;
|
||||||
this.libraryService.setEntry(this.entry);
|
this.libraryService.updateEntry(this.entry);
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.log(`Error updating entry: `, error);
|
console.log(`Error updating entry: `, error);
|
||||||
@@ -310,7 +310,7 @@ export class AlternateEntryPageComponent implements OnInit {
|
|||||||
// console.log(`Entry updated: `, entry);
|
// console.log(`Entry updated: `, entry);
|
||||||
this.entry = entry;
|
this.entry = entry;
|
||||||
this.entry.isInLibrary = true;
|
this.entry.isInLibrary = true;
|
||||||
this.libraryService.setEntry(this.entry);
|
this.libraryService.updateEntry(this.entry);
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.log(`Error updating entry: `, error);
|
console.log(`Error updating entry: `, error);
|
||||||
@@ -740,7 +740,7 @@ export class AlternateEntryPageComponent implements OnInit {
|
|||||||
this.entry.showInCalendar = result.entry.showInCalendar;
|
this.entry.showInCalendar = result.entry.showInCalendar;
|
||||||
this.entry.autoSync = result.entry.autoSync;
|
this.entry.autoSync = result.entry.autoSync;
|
||||||
|
|
||||||
this.libraryService.setEntry(this.entry);
|
this.libraryService.updateEntry(this.entry);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,16 +79,16 @@ export class EntryPageComponent implements OnInit {
|
|||||||
this.entry.collections = this.entry.collections.map((c) => {
|
this.entry.collections = this.entry.collections.map((c) => {
|
||||||
c.mediasCount = c.medias.length;
|
c.mediasCount = c.medias.length;
|
||||||
c.selectedBackdrop = this.getCollectionBackdropPath(c);
|
c.selectedBackdrop = this.getCollectionBackdropPath(c);
|
||||||
|
|
||||||
c.medias = [];
|
|
||||||
return c;
|
return c;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.entry.is_tvseries) {
|
if (this.entry.is_tvseries) {
|
||||||
// ? sorting seasons
|
// ! sorting seasons
|
||||||
this.entry.seasons = this.entry.seasons.sort((a, b) => {
|
this.entry.seasons = this.entry.seasons.sort((a, b) => {
|
||||||
if (b.season_number == 0) b.season_number = 30; // this will make the special season go last
|
// ? by changing the season number of 'special' season to 999
|
||||||
if (a.season_number == 0) a.season_number = 30; // this will make the special season go last
|
// ? it will show up as the last season.
|
||||||
|
if (b.season_number == 0) b.season_number = 999; // this will make the special season go last
|
||||||
|
if (a.season_number == 0) a.season_number = 999; // this will make the special season go last
|
||||||
|
|
||||||
return a.season_number - b.season_number;
|
return a.season_number - b.season_number;
|
||||||
});
|
});
|
||||||
@@ -145,7 +145,7 @@ export class EntryPageComponent implements OnInit {
|
|||||||
if (entryRatings) {
|
if (entryRatings) {
|
||||||
// TODO show notification
|
// TODO show notification
|
||||||
this.entry.entryRating = entryRatings;
|
this.entry.entryRating = entryRatings;
|
||||||
this.libraryService.setEntry(this.entry);
|
this.libraryService.updateEntry(this.entry);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
@@ -179,6 +179,7 @@ export class EntryPageComponent implements OnInit {
|
|||||||
let watchDate = result.watchDate;
|
let watchDate = result.watchDate;
|
||||||
let watchedWith = result.watchedWith.split('\n').join(', ');
|
let watchedWith = result.watchedWith.split('\n').join(', ');
|
||||||
|
|
||||||
|
// * Update
|
||||||
if (entrySeen.id) {
|
if (entrySeen.id) {
|
||||||
const es = {
|
const es = {
|
||||||
id: entrySeen.id,
|
id: entrySeen.id,
|
||||||
@@ -186,15 +187,25 @@ export class EntryPageComponent implements OnInit {
|
|||||||
seen_with: watchedWith,
|
seen_with: watchedWith,
|
||||||
} as EntrySeen;
|
} as EntrySeen;
|
||||||
|
|
||||||
// * Update
|
|
||||||
this.entrySeenService.updateEntrySeen(es).subscribe({
|
this.entrySeenService.updateEntrySeen(es).subscribe({
|
||||||
next: (updatedEntrySeen) => {
|
next: (updatedEntrySeen) => {
|
||||||
if (updatedEntrySeen) {
|
// TODO show confirm notification
|
||||||
// TODO show confirm notification
|
// ? replace the entry-seen object with the updated one
|
||||||
// ? replace the entry-seen object with the updated one
|
for (let i = 0; i < this.entry.entrySeen.length; i++) {
|
||||||
for (let i = 0; i < this.entry.entrySeen.length; i++) {
|
if (this.entry.entrySeen[i].id == updatedEntrySeen.id) {
|
||||||
if (this.entry.entrySeen[i].id == updatedEntrySeen.id)
|
this.entry.entrySeen[i] = updatedEntrySeen;
|
||||||
this.entry.entrySeen[i] = updatedEntrySeen;
|
|
||||||
|
// ? update enrty last_seen & first_seen dates
|
||||||
|
if (this.entry.date_last_seen < entrySeen.date_seen) {
|
||||||
|
this.entry.date_last_seen = entrySeen.date_seen;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.entry.date_first_seen > entrySeen.date_seen) {
|
||||||
|
this.entry.date_first_seen = entrySeen.date_seen;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.libraryService.updateEntry(this.entry);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -215,12 +226,25 @@ export class EntryPageComponent implements OnInit {
|
|||||||
// ? if the entry was in watch list creating and entry-seen would have removed it
|
// ? if the entry was in watch list creating and entry-seen would have removed it
|
||||||
// ? from the watchlist, so now we need to refrech libraryService in order to
|
// ? from the watchlist, so now we need to refrech libraryService in order to
|
||||||
// ? update the watchlist page
|
// ? update the watchlist page
|
||||||
if (this.entry.watchlist) {
|
this.entry.isInLibrary = true;
|
||||||
this.entry.watchlist = false;
|
this.entry.watchlist = false;
|
||||||
this.libraryService.setEntry(this.entry);
|
|
||||||
|
|
||||||
// this.libraryService.refetchEntries().subscribe();
|
// ? update enrty last_seen & first_seen dates
|
||||||
|
if (
|
||||||
|
!this.entry.date_last_seen ||
|
||||||
|
this.entry.date_last_seen < entrySeen.date_seen
|
||||||
|
) {
|
||||||
|
this.entry.date_last_seen = entrySeen.date_seen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!this.entry.date_first_seen ||
|
||||||
|
this.entry.date_first_seen > entrySeen.date_seen
|
||||||
|
) {
|
||||||
|
this.entry.date_first_seen = entrySeen.date_seen;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.libraryService.updateEntry(this.entry);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
@@ -286,7 +310,7 @@ export class EntryPageComponent implements OnInit {
|
|||||||
// console.log(`Entry updated: `, entry);
|
// console.log(`Entry updated: `, entry);
|
||||||
this.entry.favorit = entry.favorit;
|
this.entry.favorit = entry.favorit;
|
||||||
this.entry.isInLibrary = true;
|
this.entry.isInLibrary = true;
|
||||||
this.libraryService.setEntry(this.entry);
|
this.libraryService.updateEntry(this.entry);
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.log(`Error updating entry: `, error);
|
console.log(`Error updating entry: `, error);
|
||||||
@@ -308,7 +332,7 @@ export class EntryPageComponent implements OnInit {
|
|||||||
next: (entry) => {
|
next: (entry) => {
|
||||||
this.entry.hidden = entry.hidden;
|
this.entry.hidden = entry.hidden;
|
||||||
this.entry.isInLibrary = true;
|
this.entry.isInLibrary = true;
|
||||||
this.libraryService.setEntry(this.entry);
|
this.libraryService.updateEntry(this.entry);
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.log(`Error updating entry: `, error);
|
console.log(`Error updating entry: `, error);
|
||||||
@@ -337,11 +361,10 @@ export class EntryPageComponent implements OnInit {
|
|||||||
this.entry.collections = result.collections.map((c) => {
|
this.entry.collections = result.collections.map((c) => {
|
||||||
c.mediasCount = c.medias.length;
|
c.mediasCount = c.medias.length;
|
||||||
c.selectedBackdrop = this.getCollectionBackdropPath(c);
|
c.selectedBackdrop = this.getCollectionBackdropPath(c);
|
||||||
|
|
||||||
c.medias = [];
|
|
||||||
return c;
|
return c;
|
||||||
});
|
});
|
||||||
result.collections;
|
|
||||||
|
this.libraryService.updateEntry(this.entry);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -738,7 +761,7 @@ export class EntryPageComponent implements OnInit {
|
|||||||
this.entry.showInCalendar = result.entry.showInCalendar;
|
this.entry.showInCalendar = result.entry.showInCalendar;
|
||||||
this.entry.autoSync = result.entry.autoSync;
|
this.entry.autoSync = result.entry.autoSync;
|
||||||
|
|
||||||
this.libraryService.setEntry(this.entry);
|
this.libraryService.updateEntry(this.entry);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
|
|||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.getDefaultViewMode();
|
this.getDefaultViewMode();
|
||||||
|
|
||||||
this.pageSize = await this.getDefaultTableSize();
|
this.pageSize = this.getDefaultTableSize();
|
||||||
await this.getEntries(true);
|
this.getEntries();
|
||||||
// this.router.events.subscribe((event) => {
|
// this.router.events.subscribe((event) => {
|
||||||
// if (event instanceof NavigationEnd && event.url === '/library') {
|
// if (event instanceof NavigationEnd && event.url === '/library') {
|
||||||
// this.pageSize = this.getDefaultPageSize();
|
// this.pageSize = this.getDefaultPageSize();
|
||||||
@@ -139,7 +139,7 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ? uses libraryService to get library all entries
|
// ? uses libraryService to get library all entries
|
||||||
getEntries(forceFetch: boolean = false) {
|
getEntries() {
|
||||||
this.libraryService.newGetAllEntries().subscribe({
|
this.libraryService.newGetAllEntries().subscribe({
|
||||||
next: (entries) => {
|
next: (entries) => {
|
||||||
this.entries = entries.filter((e) => !e.watchlist);
|
this.entries = entries.filter((e) => !e.watchlist);
|
||||||
|
|||||||
Reference in new issue
Block a user