F: Fixed tvseries 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
6a102f86e8
commit
2a43e9108e
2 files changed
+64
-15
No files matched your search
@@ -232,7 +232,6 @@ export class EntryPageComponent implements OnInit {
|
||||
// ? 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
|
||||
// ? update the watchlist page
|
||||
this.entry.isInLibrary = true;
|
||||
this.entry.watchlist = false;
|
||||
|
||||
// ? update enrty last_seen & first_seen dates
|
||||
@@ -488,7 +487,7 @@ export class EntryPageComponent implements OnInit {
|
||||
|
||||
// mapping
|
||||
data.forEach((item) => {
|
||||
let e = {
|
||||
const episodeSeenCreateDto = {
|
||||
id: item.id,
|
||||
|
||||
entryId: item.entry_id,
|
||||
@@ -504,7 +503,7 @@ export class EntryPageComponent implements OnInit {
|
||||
updatedAt: item.updatedAt,
|
||||
} as EpisodeSeenCreateDto;
|
||||
|
||||
episodeSeens.push(e);
|
||||
episodeSeens.push(episodeSeenCreateDto);
|
||||
});
|
||||
|
||||
this.seenHistory = episodeSeens;
|
||||
@@ -534,9 +533,7 @@ export class EntryPageComponent implements OnInit {
|
||||
}
|
||||
|
||||
addEpisodeSeen() {
|
||||
if (!this.entry) return;
|
||||
|
||||
this.seenHistory[0];
|
||||
if (!this.entry || !this.entry.is_tvseries) return;
|
||||
|
||||
const dialogRef = this.dialog.open(EpisodeSeenModalComponent, {
|
||||
width: '360px',
|
||||
@@ -550,9 +547,27 @@ export class EntryPageComponent implements OnInit {
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
// ? if an episode-seen was created then refresh the watch history table
|
||||
if (result && result.created) {
|
||||
// TODO: improve this logic, there shouldn't be a need to whole recall
|
||||
// ? call this function to fetch the new episode-seen history
|
||||
this.getEpisodesSeenHistory();
|
||||
|
||||
this.entry.watchlist = false;
|
||||
|
||||
// ? update enrty last_seen & first_seen dates
|
||||
if (
|
||||
!this.entry.date_last_seen ||
|
||||
this.entry.date_last_seen < result.episodeSeen.date_seen
|
||||
) {
|
||||
this.entry.date_last_seen = result.episodeSeen.date_seen;
|
||||
}
|
||||
|
||||
if (
|
||||
!this.entry.date_first_seen ||
|
||||
this.entry.date_first_seen > result.episodeSeen.date_seen
|
||||
) {
|
||||
this.entry.date_first_seen = result.episodeSeen.date_seen;
|
||||
}
|
||||
|
||||
// ? Updating the episodes seen progress bar in the season card
|
||||
// ? by fetching a new updated episodes list
|
||||
this.entry.seasons.forEach(async (season) => {
|
||||
@@ -572,6 +587,8 @@ export class EntryPageComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.libraryService.updateEntry(this.entry);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -588,11 +605,29 @@ export class EntryPageComponent implements OnInit {
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result == null) return;
|
||||
if (!result.updated) return;
|
||||
if (result && result.updated) {
|
||||
// ? call this function to fetch the new episode-seen history
|
||||
this.getEpisodesSeenHistory();
|
||||
|
||||
// ? call this function to fetch the new episode-seen history
|
||||
this.getEpisodesSeenHistory();
|
||||
this.entry.watchlist = false;
|
||||
|
||||
// ? update enrty last_seen & first_seen dates
|
||||
if (
|
||||
!this.entry.date_last_seen ||
|
||||
this.entry.date_last_seen < result.episodeSeen.date_seen
|
||||
) {
|
||||
this.entry.date_last_seen = result.episodeSeen.date_seen;
|
||||
}
|
||||
|
||||
if (
|
||||
!this.entry.date_first_seen ||
|
||||
this.entry.date_first_seen > result.episodeSeen.date_seen
|
||||
) {
|
||||
this.entry.date_first_seen = result.episodeSeen.date_seen;
|
||||
}
|
||||
|
||||
this.libraryService.updateEntry(this.entry);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -609,20 +644,26 @@ export class EntryPageComponent implements OnInit {
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result) {
|
||||
if (result.confirmed != true) return;
|
||||
|
||||
if (result && result.confirmed) {
|
||||
// first start by calling the service and deleting the episode-seen
|
||||
this.episodeSeenService.removeEpisodeSeen(episodeSeen.id).subscribe({
|
||||
next: () => {
|
||||
// console.log(`Episode seen deleted.`);
|
||||
// ? call this function to fetch the new episode-seen history
|
||||
// this.getEpisodesSeenHistory();
|
||||
this.seenHistory = this.seenHistory.filter(
|
||||
(eps) => eps.id != episodeSeen.id
|
||||
);
|
||||
this.filterEpisodesSeenHistory();
|
||||
|
||||
// ? update enrty last_seen & first_seen dates
|
||||
if (this.seenHistory.length == 0) {
|
||||
this.entry.date_last_seen = null;
|
||||
this.entry.date_first_seen = null;
|
||||
} else {
|
||||
this.entry.date_last_seen = this.seenHistory[0].date_seen;
|
||||
this.entry.date_first_seen =
|
||||
this.seenHistory[this.seenHistory.length - 1].date_seen;
|
||||
}
|
||||
|
||||
// ? Updating the episodes seen progress bar in the season card
|
||||
// ? by fetching a new updated episodes list
|
||||
this.entry.seasons.forEach(async (season) => {
|
||||
@@ -642,6 +683,8 @@ export class EntryPageComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.libraryService.updateEntry(this.entry);
|
||||
// TODO show notification
|
||||
},
|
||||
error: (error) => {
|
||||
|
||||
+6
@@ -155,6 +155,11 @@ export class EpisodeSeenModalComponent {
|
||||
if (episodeSeen) {
|
||||
return this.dialogRef.close({
|
||||
updated: true,
|
||||
episodeSeen: {
|
||||
...this.episodeSeen,
|
||||
date_seen: episodeSeen.date_seen,
|
||||
seen_with: episodeSeen.seen_with,
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -177,6 +182,7 @@ export class EpisodeSeenModalComponent {
|
||||
if (episodeSeen) {
|
||||
return this.dialogRef.close({
|
||||
created: true,
|
||||
episodeSeen: episodeSeen,
|
||||
// ? returning the season number so it can be used to refrech the-
|
||||
// ? season card progress bar in the entry page
|
||||
season_number: this.selectedSeason?.season_number,
|
||||
|
||||
Reference in new issue
Block a user