Updating stash button locally on actor and scene page.
This commit is contained in:
		
							parent
							
								
									bb949e0a3b
								
							
						
					
					
						commit
						07643870cd
					
				|  | @ -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, | ||||
|  |  | |||
|  | @ -52,14 +52,14 @@ | |||
| 				</h2> | ||||
| 
 | ||||
| 				<Icon | ||||
| 					v-show="me && release.isStashed" | ||||
| 					v-show="me && stashed" | ||||
| 					icon="heart7" | ||||
| 					class="stash stashed noselect" | ||||
| 					@click="unstashScene" | ||||
| 				/> | ||||
| 
 | ||||
| 				<Icon | ||||
| 					v-show="me && !release.isStashed" | ||||
| 					v-show="me && !stashed" | ||||
| 					icon="heart8" | ||||
| 					class="stash unstashed noselect" | ||||
| 					@click="stashScene" | ||||
|  | @ -249,26 +249,36 @@ async function fetchRelease(scroll = true) { | |||
| 	if (scroll && this.$refs.content) { | ||||
| 		this.$refs.content.scrollTop = 0; | ||||
| 	} | ||||
| 
 | ||||
| 	this.stashed = this.release.isStashed; | ||||
| } | ||||
| 
 | ||||
| async function stashScene() { | ||||
| 	this.$store.dispatch(this.$route.name === 'movie' ? 'stashMovie' : 'stashScene', { | ||||
| 		sceneId: this.release.id, | ||||
| 		movieId: this.release.id, | ||||
| 		stashId: this.$store.getters.favorites.id, | ||||
| 	}); | ||||
| 	this.stashed = true; | ||||
| 
 | ||||
| 	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() { | ||||
| 	this.$store.dispatch(this.$route.name === 'movie' ? 'unstashMovie' : 'unstashScene', { | ||||
| 		sceneId: this.release.id, | ||||
| 		movieId: this.release.id, | ||||
| 		stashId: this.$store.getters.favorites.id, | ||||
| 	}); | ||||
| 	this.stashed = false; | ||||
| 
 | ||||
| 	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() { | ||||
|  | @ -304,6 +314,7 @@ export default { | |||
| 	data() { | ||||
| 		return { | ||||
| 			release: null, | ||||
| 			stashed: false, | ||||
| 		}; | ||||
| 	}, | ||||
| 	computed: { | ||||
|  |  | |||
|  | @ -451,7 +451,7 @@ export default { | |||
| 	.tile.new .poster::after { | ||||
| 		bottom: 0; | ||||
| 		top: auto; | ||||
| 		margin: 0 .25rem; | ||||
| 		margin: .1rem .25rem; | ||||
| 	} | ||||
| 
 | ||||
| 	.stash { | ||||
|  |  | |||
|  | @ -101,6 +101,9 @@ export default { | |||
| 	margin: 0; | ||||
| 	font-size: 1.5rem; | ||||
| 	color: var(--text-light); | ||||
| 	overflow: hidden; | ||||
| 	white-space: nowrap; | ||||
| 	text-overflow: ellipsis; | ||||
| } | ||||
| 
 | ||||
| .section { | ||||
|  |  | |||
|  | @ -246,6 +246,7 @@ function initActorActions(store, router) { | |||
| 						} | ||||
| 						totalCount | ||||
|                     } | ||||
| 					isStashed | ||||
| 					stashes: stashesActors( | ||||
| 						filter: { | ||||
| 							stash: { | ||||
|  |  | |||
|  | @ -12,6 +12,7 @@ const schemaExtender = makeExtendSchemaPlugin(_build => ({ | |||
|         } | ||||
| 
 | ||||
|       extend type Actor { | ||||
| 		isStashed: Boolean @requires(columns: ["stashesActors"]) | ||||
|         ageFromBirth: Int @requires(columns: ["dateOfBirth"]) | ||||
|         ageAtDeath: Int @requires(columns: ["dateOfBirth", "dateOfDeath"]) | ||||
|         height(units:Units): String @requires(columns: ["height"]) | ||||
|  | @ -22,6 +23,13 @@ const schemaExtender = makeExtendSchemaPlugin(_build => ({ | |||
|     `,
 | ||||
| 	resolvers: { | ||||
| 		Actor: { | ||||
| 			isStashed(parent) { | ||||
| 				if (!parent['@stashes']) { | ||||
| 					return null; | ||||
| 				} | ||||
| 
 | ||||
| 				return parent['@stashes'].length > 0; | ||||
| 			}, | ||||
| 			ageFromBirth(parent, _args, _context, _info) { | ||||
| 				if (!parent.dateOfBirth) return null; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue