Fixed heart icon in other user's stashes. Syncing stashes to session on creation and removal.

This commit is contained in:
2024-04-02 02:50:24 +02:00
parent eb423b4886
commit 5f2b696b23
4 changed files with 61 additions and 19 deletions

View File

@@ -28,19 +28,37 @@
</template>
</VDropdown>
<Icon
v-if="itemStashes.some((itemStash) => itemStash.id === currentStash.id)"
:icon="currentStash.isPrimary ? 'heart7' : 'folder-heart'"
class="heart favorited noselect"
@click.native.stop="unstashItem(currentStash)"
/>
<template v-if="pageStash?.user.id === user.id">
<Icon
v-if="itemStashes.some((itemStash) => itemStash.id === pageStash.id)"
:icon="pageStash.isPrimary ? 'heart7' : 'folder-heart'"
class="heart favorited noselect"
@click.native.stop="unstashItem(pageStash)"
/>
<Icon
v-else
:icon="currentStash.isPrimary ? 'heart8' : 'folder-heart'"
class="heart noselect"
@click.native.stop="stashItem(currentStash)"
/>
<Icon
v-else
:icon="pageStash.isPrimary ? 'heart8' : 'folder-heart'"
class="heart noselect"
@click.native.stop="stashItem(pageStash)"
/>
</template>
<template v-else>
<Icon
v-if="itemStashes.some((itemStash) => itemStash.id === user.primaryStash.id)"
icon="heart7"
class="heart favorited noselect"
@click.native.stop="unstashItem(user.primaryStash)"
/>
<Icon
v-else
icon="heart8"
class="heart noselect"
@click.native.stop="stashItem(user.primaryStash)"
/>
</template>
</div>
</template>
@@ -71,7 +89,7 @@ const props = defineProps({
const emit = defineEmits(['stashed', 'unstashed']);
const { user, pageProps } = inject('pageContext');
const currentStash = pageProps.stash || user?.primaryStash;
const pageStash = pageProps.stash;
const itemStashes = ref(props.item.stashes);