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