1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-03 04:25:24 +02:00

fix: shopping list label editor (#1333)

* remove head props

* lazily compute itemsByLabel with watcher on fetch

* remove unused import
This commit is contained in:
Hayden 2022-06-02 09:12:05 -08:00 committed by GitHub
parent 52fbf6b833
commit 5a0c034391
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 10 deletions

View file

@ -130,7 +130,6 @@ import { validators } from "~/composables/use-validators";
import { useUserApi } from "~/composables/api";
import { IngredientFood } from "~/types/api-types/recipe";
import MultiPurposeLabel from "~/components/Domain/ShoppingList/MultiPurposeLabel.vue";
import { MultiPurposeLabelSummary } from "~/types/api-types/labels";
import { useLocales } from "~/composables/use-locales";
import { useFoodStore, useLabelStore } from "~/composables/store";

View file

@ -187,7 +187,7 @@
<script lang="ts">
import draggable from "vuedraggable";
import { defineComponent, useAsync, useRoute, computed, ref } from "@nuxtjs/composition-api";
import { defineComponent, useAsync, useRoute, computed, ref, watch } from "@nuxtjs/composition-api";
import { useToggle } from "@vueuse/core";
import { useCopyList } from "~/composables/use-copy";
import { useUserApi } from "~/composables/api";
@ -367,11 +367,13 @@ export default defineComponent({
return labels;
});
const itemsByLabel = computed(() => {
const items: { [prop: string]: ShoppingListItemCreate[] } = {};
const itemsByLabel = ref<{ [key: string]: ShoppingListItemOut[] }>({});
function updateItemsByLabel() {
const items: { [prop: string]: ShoppingListItemOut[] } = {};
const noLabel = {
"No Label": [] as ShoppingListItemCreate[],
"No Label": [] as ShoppingListItemOut[],
};
shoppingList.value?.listItems?.forEach((item) => {
@ -394,7 +396,11 @@ export default defineComponent({
items["No Label"] = noLabel["No Label"];
}
return items;
itemsByLabel.value = items;
}
watch(shoppingList, () => {
updateItemsByLabel();
});
async function refreshLabels() {