fixed entry genres not showing up after updating favorit/hidden status
This commit is contained in:
1 parent
5807652843
commit
dde494a11e
2 files changed
+27
-21
No files matched your search
@@ -91,7 +91,7 @@ entryRouter.post('/', async (req, res) => {
|
||||
res.status(201).json(entry);
|
||||
});
|
||||
|
||||
// * POST - BULK IMPORT MOVIES
|
||||
// ! import routes
|
||||
entryRouter.post('/bulk-import-movies', async (req, res) => {
|
||||
const { movies } = req.body;
|
||||
|
||||
@@ -131,8 +131,7 @@ entryRouter.post('/bulk-import-episodes-seen', async (req, res) => {
|
||||
|
||||
res.status(201).json(createdRows);
|
||||
});
|
||||
|
||||
|
||||
// + import routes end
|
||||
// * PUT - ENTRY UPDATE
|
||||
entryRouter.put('/:id', async (req, res) => {
|
||||
const { id } = req.params;
|
||||
@@ -159,7 +158,7 @@ entryRouter.put('/:id', async (req, res) => {
|
||||
{
|
||||
model: Genre,
|
||||
as: 'genres',
|
||||
attributes: ['id'],
|
||||
attributes: ['name'],
|
||||
through: {
|
||||
attributes: []
|
||||
}
|
||||
@@ -168,22 +167,30 @@ entryRouter.put('/:id', async (req, res) => {
|
||||
|
||||
if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' });
|
||||
|
||||
const entry = await Entry.findByPk(id, {
|
||||
const updatedEntry = await Entry.findByPk(id, {
|
||||
include: includes
|
||||
});
|
||||
|
||||
res.status(201).json(entry);
|
||||
const entryData = updatedEntry.get({ plain: true });
|
||||
const genres = entryData.genres.map(genre => genre.name);
|
||||
|
||||
entryData.genres = genres;
|
||||
|
||||
res.status(201).json(entryData);
|
||||
});
|
||||
|
||||
// * GET - REQUEST ENTRY UPDATE
|
||||
// * GET - REQUEST ENTRY REFRECH
|
||||
entryRouter.get('/:id/refrech', async (req, res) => {
|
||||
const { id } = req.params;
|
||||
|
||||
// ? checking if the provied id is valid
|
||||
// ! note: the includes are required for the update
|
||||
const oldEntry = await Entry.findByPk(id, {
|
||||
include: [
|
||||
{ model: EntryId, as: 'entryId' },
|
||||
{ model: EntryRating, as: 'entryRating' },
|
||||
{ model: EntrySeen, as: 'entrySeen' },
|
||||
{ model: Season, as: 'seasons' },
|
||||
{
|
||||
model: Genre,
|
||||
as: 'genres',
|
||||
@@ -198,7 +205,6 @@ entryRouter.get('/:id/refrech', async (req, res) => {
|
||||
if (!oldEntry)
|
||||
return res.status(404).json({ message: `Entry id not found` });
|
||||
|
||||
|
||||
// ? getting new data from TMDB
|
||||
const data = await fetchEntryData(oldEntry.entryId.tmdb_id, oldEntry.is_tvseries);
|
||||
if (data == null) return res.status(500).json({ message: `Counldn't fetch data from TMDB` });
|
||||
@@ -211,6 +217,7 @@ entryRouter.get('/:id/refrech', async (req, res) => {
|
||||
{ model: EntryId, as: 'entryId' },
|
||||
{ model: EntryRating, as: 'entryRating' },
|
||||
{ model: EntrySeen, as: 'entrySeen' },
|
||||
{ model: Season, as: 'seasons' },
|
||||
{
|
||||
model: Genre,
|
||||
as: 'genres',
|
||||
@@ -220,17 +227,14 @@ entryRouter.get('/:id/refrech', async (req, res) => {
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
if (oldEntry.is_tvseries) includes.push({ model: Season, as: 'seasons' });
|
||||
|
||||
const entry = await Entry.findByPk(id, {
|
||||
const updatedEntry = await Entry.findByPk(id, {
|
||||
include: includes
|
||||
});
|
||||
|
||||
const entryData = entry.get({ plain: true });
|
||||
const genres = entryData.genres.map(genre => genre.name);
|
||||
|
||||
entryData.genres = genres;
|
||||
const entryData = updatedEntry.get({ plain: true });
|
||||
entryData.genres = entryData.genres.map(genre => genre.name);
|
||||
|
||||
res.status(201).json(entryData);
|
||||
});
|
||||
|
||||
@@ -70,6 +70,7 @@ export class EntryPageComponent implements OnInit {
|
||||
this.route.data.subscribe(
|
||||
(data) => {
|
||||
this.entry = data['entry'] as Entry;
|
||||
// console.log(this.entry);
|
||||
|
||||
if (this.entry.is_tvseries) {
|
||||
// ? sorting seasons
|
||||
@@ -90,7 +91,7 @@ export class EntryPageComponent implements OnInit {
|
||||
season.episodes = episodes;
|
||||
},
|
||||
error: (error) => {
|
||||
console.log(`Couldn't fetch season episodes data:`, error);
|
||||
// console.log(`Couldn't fetch season episodes data:`, error);
|
||||
this.toastr.success(
|
||||
'Error',
|
||||
`Couldn't get season ${season.season_number} episodes.`,
|
||||
@@ -163,7 +164,7 @@ export class EntryPageComponent implements OnInit {
|
||||
|
||||
// TODO show notification
|
||||
} else {
|
||||
console.log('Seen dialog was cancelled');
|
||||
// console.log('Seen dialog was cancelled');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -251,7 +252,7 @@ export class EntryPageComponent implements OnInit {
|
||||
},
|
||||
complete: () => {
|
||||
this.lockActions = false;
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -266,7 +267,8 @@ export class EntryPageComponent implements OnInit {
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
console.log('Modal Closed: ', result);
|
||||
// TODO update entry page collections
|
||||
// console.log('Modal Closed: ', result);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -368,7 +370,8 @@ export class EntryPageComponent implements OnInit {
|
||||
// console.log('Episode seen dialog closed with:', result);
|
||||
if (result.watchDate == '') {
|
||||
// TODO show no date was passed notification
|
||||
return console.log(`Episode seen dialog closed with no date.`);
|
||||
console.log(`Episode seen dialog closed with no date.`);
|
||||
return;
|
||||
}
|
||||
|
||||
episodeSeen.date_seen = result.watchDate;
|
||||
@@ -402,7 +405,6 @@ export class EntryPageComponent implements OnInit {
|
||||
|
||||
dialogRef.afterClosed().subscribe((result) => {
|
||||
if (result) {
|
||||
console.log(result);
|
||||
if (result.confirmed != true) return;
|
||||
|
||||
// first start by calling the service and deleting the episode-seen
|
||||
@@ -442,7 +444,7 @@ export class EntryPageComponent implements OnInit {
|
||||
}
|
||||
|
||||
triggerEpisodeWatchedDeletedEvent() {
|
||||
console.log(`Emitted Episode Watched Deleted Event`);
|
||||
// console.log(`Emitted Episode Watched Deleted Event`);
|
||||
}
|
||||
|
||||
// + end EPISODE SEEN
|
||||
|
||||
Reference in new issue
Block a user