Fixed heart menu stash creation.
This commit is contained in:
		
							parent
							
								
									b683653af4
								
							
						
					
					
						commit
						0d383c35b5
					
				| 
						 | 
				
			
			@ -82,7 +82,8 @@
 | 
			
		|||
 | 
			
		||||
		<StashDialog
 | 
			
		||||
			v-if="showStashDialog"
 | 
			
		||||
			@created="showStashDialog = false; reloadStashes();"
 | 
			
		||||
			@created="(newStash) => { showStashDialog = false; reloadStashes(newStash); }"
 | 
			
		||||
			@close="showStashDialog = false;"
 | 
			
		||||
		/>
 | 
			
		||||
	</div>
 | 
			
		||||
</template>
 | 
			
		||||
| 
						 | 
				
			
			@ -114,9 +115,10 @@ const props = defineProps({
 | 
			
		|||
 | 
			
		||||
const emit = defineEmits(['stashed', 'unstashed']);
 | 
			
		||||
 | 
			
		||||
const { user, pageProps } = inject('pageContext');
 | 
			
		||||
const pageStash = pageProps.stash;
 | 
			
		||||
const pageContext = inject('pageContext');
 | 
			
		||||
const pageStash = pageContext.pageProps.stash;
 | 
			
		||||
 | 
			
		||||
const user = ref(pageContext.user);
 | 
			
		||||
const itemStashes = ref(props.item.stashes);
 | 
			
		||||
const hasSecondaryStash = computed(() => itemStashes.value.some((itemStash) => !itemStash.isPrimary));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -192,10 +194,12 @@ function toggleShowStashes(state) {
 | 
			
		|||
	showStashes.value = !showStashes.value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function reloadStashes() {
 | 
			
		||||
	const profile = await get(`/users/${user.id}`);
 | 
			
		||||
async function reloadStashes(newStash) {
 | 
			
		||||
	const profile = await get(`/users/${user.value.id}`);
 | 
			
		||||
 | 
			
		||||
	console.log(profile);
 | 
			
		||||
	user.value = profile;
 | 
			
		||||
 | 
			
		||||
	await stashItem(newStash);
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,6 +15,7 @@
 | 
			
		|||
 | 
			
		||||
		<li class="menu-item create">
 | 
			
		||||
			<label
 | 
			
		||||
				v-close-popper
 | 
			
		||||
				class="menu-stash"
 | 
			
		||||
				@click="emit('create')"
 | 
			
		||||
			>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -142,11 +142,11 @@ export async function createStash(newStash, sessionUser) {
 | 
			
		|||
	verifyStashName(newStash);
 | 
			
		||||
 | 
			
		||||
	try {
 | 
			
		||||
		const stash = await knex('stashes')
 | 
			
		||||
		const [stash] = await knex('stashes')
 | 
			
		||||
			.insert(curateStashEntry(newStash, sessionUser))
 | 
			
		||||
			.returning('*');
 | 
			
		||||
 | 
			
		||||
		const curatedStash = curateStash(stash);
 | 
			
		||||
		const curatedStash = curateStash(stash, { user: sessionUser });
 | 
			
		||||
 | 
			
		||||
		return curatedStash;
 | 
			
		||||
	} catch (error) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue