Added sections and pagination to stash page.
This commit is contained in:
@@ -136,20 +136,30 @@ function curateTag(tag) {
|
||||
function curateStash(stash) {
|
||||
const curatedStash = stash;
|
||||
|
||||
if (stash.scenes) {
|
||||
curatedStash.scenes = stash.scenes.map(item => ({
|
||||
if (stash.scenes || stash.scenesConnection?.scenes) {
|
||||
curatedStash.sceneTotal = stash.scenesConnection?.totalCount || null;
|
||||
curatedStash.scenes = (stash.scenesConnection?.scenes || stash.scenes).map(item => ({
|
||||
...item,
|
||||
scene: curateRelease(item.scene),
|
||||
}));
|
||||
}
|
||||
|
||||
if (stash.actors) {
|
||||
curatedStash.actors = stash.actors.map(item => ({
|
||||
if (stash.actors || stash.actorsConnection?.actors) {
|
||||
curatedStash.actorTotal = stash.actorsConnection?.totalCount || null;
|
||||
curatedStash.actors = (stash.actorsConnection?.actors || stash.actors).map(item => ({
|
||||
...item,
|
||||
actor: curateActor(item.actor),
|
||||
}));
|
||||
}
|
||||
|
||||
if (stash.movies || stash.moviesConnection?.movies) {
|
||||
curatedStash.movieTotal = stash.moviesConnection?.totalCount || null;
|
||||
curatedStash.movies = (stash.moviesConnection?.movies || stash.movies).map(item => ({
|
||||
...item,
|
||||
movie: curateRelease(item.movie),
|
||||
}));
|
||||
}
|
||||
|
||||
return curatedStash;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,6 +145,24 @@ const movieFields = `
|
||||
}
|
||||
}
|
||||
}
|
||||
isFavorited
|
||||
isStashed(includeFavorites: false)
|
||||
stashes: stashesMovies(
|
||||
filter: {
|
||||
stash: {
|
||||
userId: {
|
||||
equalTo: $userId
|
||||
}
|
||||
}
|
||||
}
|
||||
) @include(if: $hasAuth) {
|
||||
stash {
|
||||
id
|
||||
name
|
||||
slug
|
||||
primary
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const campaignsFragment = `
|
||||
|
||||
@@ -72,6 +72,8 @@ function initReleasesActions(store, router) {
|
||||
query Movies(
|
||||
$limit:Int = 1000,
|
||||
$offset:Int = 0,
|
||||
$hasAuth: Boolean!
|
||||
$userId: Int
|
||||
) {
|
||||
connection: moviesConnection(
|
||||
first: $limit
|
||||
@@ -90,6 +92,8 @@ function initReleasesActions(store, router) {
|
||||
}
|
||||
}
|
||||
`, {
|
||||
hasAuth: !!store.state.auth.user,
|
||||
userId: store.state.auth.user?.id,
|
||||
limit,
|
||||
offset: Math.max(0, (pageNumber - 1)) * limit,
|
||||
});
|
||||
|
||||
@@ -228,7 +228,18 @@ const routes = [
|
||||
name: 'notifications',
|
||||
},
|
||||
{
|
||||
path: '/stash/:stashId/:stashSlug?',
|
||||
path: '/stash/:stashId/:stashSlug',
|
||||
redirect: from => ({
|
||||
name: 'stash',
|
||||
params: {
|
||||
...from.params,
|
||||
range: 'scenes',
|
||||
pageNumber: 1,
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
path: '/stash/:stashId/:stashSlug?/:range/:pageNumber',
|
||||
component: Stash,
|
||||
name: 'stash',
|
||||
},
|
||||
|
||||
@@ -5,14 +5,24 @@ import {
|
||||
patch,
|
||||
} from '../api';
|
||||
|
||||
import { releaseFields, actorStashesFields } from '../fragments';
|
||||
import { releaseFields, actorStashesFields, movieFields } from '../fragments';
|
||||
import { curateStash } from '../curate';
|
||||
|
||||
function initStashesActions(store, _router) {
|
||||
async function fetchStash(context, stashId) {
|
||||
async function fetchStash(context, {
|
||||
stashId,
|
||||
section = 'scenes',
|
||||
pageNumber = 1,
|
||||
limit = 20,
|
||||
}) {
|
||||
const { stash } = await graphql(`
|
||||
query Stash(
|
||||
$stashId: Int!
|
||||
$includeScenes: Boolean!
|
||||
$includeActors: Boolean!
|
||||
$includeMovies: Boolean!
|
||||
$limit:Int = 10,
|
||||
$offset:Int = 0,
|
||||
$hasAuth: Boolean!
|
||||
$userId: Int
|
||||
) {
|
||||
@@ -26,45 +36,77 @@ function initStashesActions(store, _router) {
|
||||
id
|
||||
username
|
||||
}
|
||||
actors: stashesActors {
|
||||
comment
|
||||
actor {
|
||||
id
|
||||
name
|
||||
slug
|
||||
gender
|
||||
age
|
||||
ageFromBirth
|
||||
dateOfBirth
|
||||
birthCity
|
||||
birthState
|
||||
birthCountry: countryByBirthCountryAlpha2 {
|
||||
alpha2
|
||||
name
|
||||
alias
|
||||
}
|
||||
avatar: avatarMedia {
|
||||
actorsConnection: stashesActorsConnection(
|
||||
orderBy: CREATED_AT_DESC
|
||||
first: $limit
|
||||
offset: $offset
|
||||
) @include(if: $includeActors) {
|
||||
totalCount
|
||||
actors: nodes {
|
||||
comment
|
||||
actor {
|
||||
id
|
||||
path
|
||||
thumbnail
|
||||
lazy
|
||||
isS3
|
||||
width
|
||||
height
|
||||
name
|
||||
slug
|
||||
gender
|
||||
age
|
||||
ageFromBirth
|
||||
dateOfBirth
|
||||
birthCity
|
||||
birthState
|
||||
birthCountry: countryByBirthCountryAlpha2 {
|
||||
alpha2
|
||||
name
|
||||
alias
|
||||
}
|
||||
avatar: avatarMedia {
|
||||
id
|
||||
path
|
||||
thumbnail
|
||||
lazy
|
||||
isS3
|
||||
width
|
||||
height
|
||||
}
|
||||
${actorStashesFields}
|
||||
}
|
||||
${actorStashesFields}
|
||||
}
|
||||
}
|
||||
scenes: stashesScenes {
|
||||
comment
|
||||
scene {
|
||||
${releaseFields}
|
||||
scenesConnection: stashesScenesConnection(
|
||||
orderBy: CREATED_AT_DESC
|
||||
first: $limit
|
||||
offset: $offset
|
||||
) @include(if: $includeScenes) {
|
||||
totalCount
|
||||
scenes: nodes {
|
||||
comment
|
||||
scene {
|
||||
${releaseFields}
|
||||
}
|
||||
}
|
||||
}
|
||||
moviesConnection: stashesMoviesConnection(
|
||||
orderBy: CREATED_AT_DESC
|
||||
first: $limit
|
||||
offset: $offset
|
||||
) @include(if: $includeMovies) {
|
||||
totalCount
|
||||
movies: nodes {
|
||||
comment
|
||||
movie {
|
||||
${movieFields}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`, {
|
||||
stashId: Number(stashId),
|
||||
includeScenes: section === 'scenes',
|
||||
includeActors: section === 'actors',
|
||||
includeMovies: section === 'movies',
|
||||
offset: Math.max(0, (pageNumber - 1)) * limit,
|
||||
limit: Number(limit),
|
||||
hasAuth: !!store.state.auth.user,
|
||||
userId: store.state.auth.user?.id,
|
||||
});
|
||||
|
||||
@@ -57,7 +57,10 @@ function initUsersActions(store, _router) {
|
||||
}
|
||||
}
|
||||
}
|
||||
scenes: stashesScenes(first: 20) {
|
||||
scenes: stashesScenes(
|
||||
first: 20
|
||||
orderBy: CREATED_AT_DESC
|
||||
) {
|
||||
comment
|
||||
scene {
|
||||
${releaseFields}
|
||||
|
||||
Reference in New Issue
Block a user