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