Fixed heart menu stash creation.

This commit is contained in:
DebaucheryLibrarian 2024-08-23 01:35:39 +02:00
parent b683653af4
commit 0d383c35b5
3 changed files with 13 additions and 8 deletions

View File

@ -82,7 +82,8 @@
<StashDialog <StashDialog
v-if="showStashDialog" v-if="showStashDialog"
@created="showStashDialog = false; reloadStashes();" @created="(newStash) => { showStashDialog = false; reloadStashes(newStash); }"
@close="showStashDialog = false;"
/> />
</div> </div>
</template> </template>
@ -114,9 +115,10 @@ const props = defineProps({
const emit = defineEmits(['stashed', 'unstashed']); const emit = defineEmits(['stashed', 'unstashed']);
const { user, pageProps } = inject('pageContext'); const pageContext = inject('pageContext');
const pageStash = pageProps.stash; const pageStash = pageContext.pageProps.stash;
const user = ref(pageContext.user);
const itemStashes = ref(props.item.stashes); const itemStashes = ref(props.item.stashes);
const hasSecondaryStash = computed(() => itemStashes.value.some((itemStash) => !itemStash.isPrimary)); const hasSecondaryStash = computed(() => itemStashes.value.some((itemStash) => !itemStash.isPrimary));
@ -192,10 +194,12 @@ function toggleShowStashes(state) {
showStashes.value = !showStashes.value; showStashes.value = !showStashes.value;
} }
async function reloadStashes() { async function reloadStashes(newStash) {
const profile = await get(`/users/${user.id}`); const profile = await get(`/users/${user.value.id}`);
console.log(profile); user.value = profile;
await stashItem(newStash);
} }
</script> </script>

View File

@ -15,6 +15,7 @@
<li class="menu-item create"> <li class="menu-item create">
<label <label
v-close-popper
class="menu-stash" class="menu-stash"
@click="emit('create')" @click="emit('create')"
> >

View File

@ -142,11 +142,11 @@ export async function createStash(newStash, sessionUser) {
verifyStashName(newStash); verifyStashName(newStash);
try { try {
const stash = await knex('stashes') const [stash] = await knex('stashes')
.insert(curateStashEntry(newStash, sessionUser)) .insert(curateStashEntry(newStash, sessionUser))
.returning('*'); .returning('*');
const curatedStash = curateStash(stash); const curatedStash = curateStash(stash, { user: sessionUser });
return curatedStash; return curatedStash;
} catch (error) { } catch (error) {