Add specific episode-seen
This commit is contained in:
1 parent
728dae4e59
commit
29d6e3f503
13 files changed
+323
-22
No files matched your search
@@ -19,6 +19,7 @@ import { SeasonService } from '../../../core/services/season.service';
|
||||
import { LibraryService } from '../../../core/services/library.service';
|
||||
import { ToastrService } from 'ngx-toastr';
|
||||
import { EntrySeen } from '../../../shared/models/entrySeen.model';
|
||||
import { EpisodeSeenModalComponent } from '../../../shared/components/modals/episode-seen-modal/episode-seen-modal.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-entry-page',
|
||||
@@ -397,6 +398,45 @@ export class EntryPageComponent implements OnInit {
|
||||
this.seenHistoryToShow = temp.slice(startIndex, endIndex);
|
||||
}
|
||||
|
||||
addEpisodeSeen() {
|
||||
if (!this.entry) return;
|
||||
|
||||
const dialogRef = this.dialog.open(EpisodeSeenModalComponent, {
|
||||
width: '360px',
|
||||
data: {
|
||||
entryId: this.entry.id,
|
||||
},
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
// ? if an episode-seen was created then refresh the watch history table
|
||||
if (result && result.created) {
|
||||
// ? call this function to fetch the new episode-seen history
|
||||
this.getEpisodesSeenHistory();
|
||||
|
||||
// ? Updating the episodes seen progress bar in the season card
|
||||
// ? by fetching a new updated episodes list
|
||||
this.entry.seasons.forEach(async (season) => {
|
||||
if (season.season_number == result.season_number) {
|
||||
this.seasonService.getSeasonEpisodes(season.id).subscribe({
|
||||
next: (episodes) => {
|
||||
// console.log(
|
||||
// `Loaded Season ${season.season_number} Episodes (${episodes.length})`
|
||||
// );
|
||||
season.episodes = episodes;
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(`Couldn't fetch season episodes data:`, error);
|
||||
// TODO show notification
|
||||
season.episodes = [];
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
editEpisodeSeen(episodeSeen: EpisodeSeenDto) {
|
||||
if (episodeSeen == null) return;
|
||||
|
||||
@@ -456,11 +496,11 @@ export class EntryPageComponent implements OnInit {
|
||||
this.episodeSeenService.removeEpisodeSeen(episodeSeen.id).subscribe({
|
||||
next: () => {
|
||||
// console.log(`Episode seen deleted.`);
|
||||
// call this function to fetch the new episode-seen history
|
||||
// ? call this function to fetch the new episode-seen history
|
||||
this.getEpisodesSeenHistory();
|
||||
|
||||
// trying to update the episodes seen progress bar in the season card
|
||||
// by fetching a new updated episodes list
|
||||
// ? Updating the episodes seen progress bar in the season card
|
||||
// ? by fetching a new updated episodes list
|
||||
this.entry.seasons.forEach(async (season) => {
|
||||
if (season.season_number == episodeSeen.season_number) {
|
||||
this.seasonService.getSeasonEpisodes(season.id).subscribe({
|
||||
|
||||
Reference in new issue
Block a user