Added series.
This commit is contained in:
@@ -141,16 +141,16 @@ function initReleasesActions(store, router) {
|
||||
};
|
||||
}
|
||||
|
||||
async function fetchMovieById({ _commit }, movieId) {
|
||||
async function fetchCollectionById({ _commit }, movieId, type = 'movie') {
|
||||
// const release = await get(`/releases/${releaseId}`);
|
||||
|
||||
const { movie } = await graphql(`
|
||||
const result = await graphql(`
|
||||
query Movie(
|
||||
$movieId: Int!
|
||||
$hasAuth: Boolean!
|
||||
$userId: Int
|
||||
) {
|
||||
movie(id: $movieId) {
|
||||
${type}(id: $movieId) {
|
||||
id
|
||||
title
|
||||
description
|
||||
@@ -182,7 +182,7 @@ function initReleasesActions(store, router) {
|
||||
isS3
|
||||
}
|
||||
}
|
||||
poster: moviesPoster {
|
||||
poster: ${type === 'series' ? 'seriesPosterBySerieId' : 'moviesPoster'} {
|
||||
media {
|
||||
id
|
||||
path
|
||||
@@ -195,7 +195,7 @@ function initReleasesActions(store, router) {
|
||||
isS3
|
||||
}
|
||||
}
|
||||
covers: moviesCovers(orderBy: MEDIA_BY_MEDIA_ID__INDEX_ASC) {
|
||||
covers: ${type === 'series' ? 'seriesCoversBySerieId' : 'moviesCovers'}(orderBy: MEDIA_BY_MEDIA_ID__INDEX_ASC) {
|
||||
media {
|
||||
id
|
||||
path
|
||||
@@ -208,14 +208,14 @@ function initReleasesActions(store, router) {
|
||||
isS3
|
||||
}
|
||||
}
|
||||
trailer: moviesTrailer {
|
||||
trailer: ${type === 'series' ? 'seriesTrailerBySerieId' : 'moviesTrailer'} {
|
||||
media {
|
||||
id
|
||||
path
|
||||
isS3
|
||||
}
|
||||
}
|
||||
scenes: moviesScenes {
|
||||
scenes: ${type === 'series' ? 'seriesScenesBySerieId' : 'moviesScenes'} {
|
||||
scene {
|
||||
${releaseFields}
|
||||
}
|
||||
@@ -259,7 +259,7 @@ function initReleasesActions(store, router) {
|
||||
hasLogo
|
||||
}
|
||||
}
|
||||
stashes: stashesMovies(
|
||||
stashes: ${type === 'series' ? 'stashesSeriesBySerieId' : 'stashesMovies'}(
|
||||
filter: {
|
||||
stash: {
|
||||
userId: {
|
||||
@@ -283,12 +283,20 @@ function initReleasesActions(store, router) {
|
||||
userId: store.state.auth.user?.id,
|
||||
});
|
||||
|
||||
if (!movie) {
|
||||
if (!result[type]) {
|
||||
router.replace('/not-found');
|
||||
return null;
|
||||
}
|
||||
|
||||
return curateRelease(movie);
|
||||
return curateRelease(result[type]);
|
||||
}
|
||||
|
||||
async function fetchMovieById(context, movieId) {
|
||||
return fetchCollectionById(context, movieId, 'movie');
|
||||
}
|
||||
|
||||
async function fetchSerieById(context, serieId) {
|
||||
return fetchCollectionById(context, serieId, 'series');
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -296,6 +304,7 @@ function initReleasesActions(store, router) {
|
||||
fetchReleaseById,
|
||||
fetchMovies,
|
||||
fetchMovieById,
|
||||
fetchSerieById,
|
||||
searchMovies,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user