Updating stash button locally on actor and scene page.

This commit is contained in:
DebaucheryLibrarian 2021-03-20 18:12:06 +01:00
parent bb949e0a3b
commit 07643870cd
6 changed files with 60 additions and 32 deletions

View File

@ -35,14 +35,14 @@
/> />
<Icon <Icon
v-show="me && isStashed" v-show="me && stashed"
icon="heart7" icon="heart7"
class="stash stashed noselect" class="stash stashed noselect"
@click="unstashActor" @click="unstashActor"
/> />
<Icon <Icon
v-show="me && !isStashed" v-show="me && !stashed"
icon="heart8" icon="heart8"
class="stash unstashed noselect" class="stash unstashed noselect"
@click="stashActor" @click="stashActor"
@ -402,6 +402,7 @@ async function fetchActor(scroll = true) {
this.actor = actor; this.actor = actor;
this.releases = releases; this.releases = releases;
this.totalCount = totalCount; this.totalCount = totalCount;
this.stashed = this.actor.isStashed;
if (this.$refs.filter && scroll) { if (this.$refs.filter && scroll) {
this.$refs.filter.$el.scrollIntoView(); this.$refs.filter.$el.scrollIntoView();
@ -409,31 +410,35 @@ async function fetchActor(scroll = true) {
} }
async function stashActor() { async function stashActor() {
this.$store.dispatch('stashActor', { this.stashed = true;
actorId: this.actor.id,
stashId: this.$store.getters.favorites.id,
});
this.fetchActor(false); try {
this.$store.dispatch('stashActor', {
actorId: this.actor.id,
stashId: this.$store.getters.favorites.id,
});
} catch (error) {
this.stashed = false;
}
} }
async function unstashActor() { async function unstashActor() {
this.$store.dispatch('unstashActor', { this.stashed = false;
actorId: this.actor.id,
stashId: this.$store.getters.favorites.id,
});
this.fetchActor(false); try {
this.$store.dispatch('unstashActor', {
actorId: this.actor.id,
stashId: this.$store.getters.favorites.id,
});
} catch (error) {
this.stashed = true;
}
} }
function me() { function me() {
return this.$store.state.auth.user; return this.$store.state.auth.user;
} }
function isStashed() {
return this.actor.stashes?.length > 0;
}
function sfw() { function sfw() {
return this.$store.state.ui.sfw; return this.$store.state.ui.sfw;
} }
@ -477,10 +482,10 @@ export default {
pageTitle: null, pageTitle: null,
bioExpanded: false, bioExpanded: false,
photosExpanded: false, photosExpanded: false,
stashed: false,
}; };
}, },
computed: { computed: {
isStashed,
me, me,
sfw, sfw,
showAlbum, showAlbum,

View File

@ -52,14 +52,14 @@
</h2> </h2>
<Icon <Icon
v-show="me && release.isStashed" v-show="me && stashed"
icon="heart7" icon="heart7"
class="stash stashed noselect" class="stash stashed noselect"
@click="unstashScene" @click="unstashScene"
/> />
<Icon <Icon
v-show="me && !release.isStashed" v-show="me && !stashed"
icon="heart8" icon="heart8"
class="stash unstashed noselect" class="stash unstashed noselect"
@click="stashScene" @click="stashScene"
@ -249,26 +249,36 @@ async function fetchRelease(scroll = true) {
if (scroll && this.$refs.content) { if (scroll && this.$refs.content) {
this.$refs.content.scrollTop = 0; this.$refs.content.scrollTop = 0;
} }
this.stashed = this.release.isStashed;
} }
async function stashScene() { async function stashScene() {
this.$store.dispatch(this.$route.name === 'movie' ? 'stashMovie' : 'stashScene', { this.stashed = true;
sceneId: this.release.id,
movieId: this.release.id,
stashId: this.$store.getters.favorites.id,
});
this.fetchRelease(false); try {
this.$store.dispatch(this.$route.name === 'movie' ? 'stashMovie' : 'stashScene', {
sceneId: this.release.id,
movieId: this.release.id,
stashId: this.$store.getters.favorites.id,
});
} catch (error) {
this.stashed = false;
}
} }
async function unstashScene() { async function unstashScene() {
this.$store.dispatch(this.$route.name === 'movie' ? 'unstashMovie' : 'unstashScene', { this.stashed = false;
sceneId: this.release.id,
movieId: this.release.id,
stashId: this.$store.getters.favorites.id,
});
this.fetchRelease(false); try {
this.$store.dispatch(this.$route.name === 'movie' ? 'unstashMovie' : 'unstashScene', {
sceneId: this.release.id,
movieId: this.release.id,
stashId: this.$store.getters.favorites.id,
});
} catch (error) {
this.stashed = true;
}
} }
function me() { function me() {
@ -304,6 +314,7 @@ export default {
data() { data() {
return { return {
release: null, release: null,
stashed: false,
}; };
}, },
computed: { computed: {

View File

@ -451,7 +451,7 @@ export default {
.tile.new .poster::after { .tile.new .poster::after {
bottom: 0; bottom: 0;
top: auto; top: auto;
margin: 0 .25rem; margin: .1rem .25rem;
} }
.stash { .stash {

View File

@ -101,6 +101,9 @@ export default {
margin: 0; margin: 0;
font-size: 1.5rem; font-size: 1.5rem;
color: var(--text-light); color: var(--text-light);
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
} }
.section { .section {

View File

@ -246,6 +246,7 @@ function initActorActions(store, router) {
} }
totalCount totalCount
} }
isStashed
stashes: stashesActors( stashes: stashesActors(
filter: { filter: {
stash: { stash: {

View File

@ -12,6 +12,7 @@ const schemaExtender = makeExtendSchemaPlugin(_build => ({
} }
extend type Actor { extend type Actor {
isStashed: Boolean @requires(columns: ["stashesActors"])
ageFromBirth: Int @requires(columns: ["dateOfBirth"]) ageFromBirth: Int @requires(columns: ["dateOfBirth"])
ageAtDeath: Int @requires(columns: ["dateOfBirth", "dateOfDeath"]) ageAtDeath: Int @requires(columns: ["dateOfBirth", "dateOfDeath"])
height(units:Units): String @requires(columns: ["height"]) height(units:Units): String @requires(columns: ["height"])
@ -22,6 +23,13 @@ const schemaExtender = makeExtendSchemaPlugin(_build => ({
`, `,
resolvers: { resolvers: {
Actor: { Actor: {
isStashed(parent) {
if (!parent['@stashes']) {
return null;
}
return parent['@stashes'].length > 0;
},
ageFromBirth(parent, _args, _context, _info) { ageFromBirth(parent, _args, _context, _info) {
if (!parent.dateOfBirth) return null; if (!parent.dateOfBirth) return null;