Prevent adding duplicate stash triggers to alert.

This commit is contained in:
DebaucheryLibrarian 2024-05-28 06:01:28 +02:00
parent f48afaeffa
commit 419a0c9362
1 changed files with 34 additions and 30 deletions

View File

@ -329,37 +329,39 @@
/>
</li>
<li class="field-add">
<button
v-if="stashes.length === 0"
type="button"
class="button favorites"
@click="selectStash(user.primaryStash)"
><Icon icon="heart7" />Add to favorites</button>
</li>
<li class="field-add">
<VDropdown>
<template v-if="stashes.length < user.stashes.length">
<li class="field-add">
<button
v-if="stashes.length === 0"
type="button"
class="button field-add"
><Icon icon="folder-heart" />Add to stash</button>
class="button favorites"
@click="selectStash(user.primaryStash)"
><Icon icon="heart7" />Add to favorites</button>
</li>
<template #popper>
<ul class="nolist">
<li
v-for="stash in user.stashes"
:key="`stash-result-${stash.id}`"
v-close-popper
class="result-item result-stash result-label"
@click="selectStash(stash)"
>
{{ stash.name }}
</li>
</ul>
</template>
</VDropdown>
</li>
<li class="field-add">
<VDropdown>
<button
type="button"
class="button field-add"
><Icon icon="folder-heart" />Add to stash</button>
<template #popper>
<ul class="nolist">
<li
v-for="stash in user.stashes.filter((stash) => !stashes.some((selectedStash) => selectedStash.id === stash.id))"
:key="`stash-result-${stash.id}`"
v-close-popper
class="result-item result-stash result-label"
@click="selectStash(stash)"
>
{{ stash.name }}
</li>
</ul>
</template>
</VDropdown>
</li>
</template>
</ul>
</div>
</div>
@ -497,8 +499,10 @@ function addMatch() {
matchExpression.value = '';
}
function selectStash(stash) {
stashes.value.push(stash);
function selectStash(selectedStash) {
if (!stashes.value.some((stash) => stash.id === selectedStash.id)) {
stashes.value.push(selectedStash);
}
}
</script>