fixed category change entry updaet

This commit is contained in:
vabene1111
2025-12-04 07:46:56 +01:00
parent d0856ce3b7
commit 17de37b9fc
3 changed files with 11 additions and 11 deletions

View File

@@ -187,7 +187,6 @@ class SpaceFilterSerializer(serializers.ListSerializer):
data = []
else:
iterable = data.all() if hasattr(data, 'all') else data
try:
if isinstance(iterable, list) or (isinstance(iterable, QuerySet) and getattr(iterable, '_result_cache', None) is not None):
data = [d for d in iterable if d.userspace.space.id == self.context['request'].space.id]
else:
@@ -196,9 +195,6 @@ class SpaceFilterSerializer(serializers.ListSerializer):
else:
# not sure why but this branch can be hit (just normal page load, need to see why)
data = data.filter(userspace__space=self.context['request'].user.get_active_space()).all()
except Exception:
# not sure why but this branch can be hit (just normal page load, need to see why)
data = data.filter(userspace__space=self.context['request'].user.get_active_space()).all()
elif isinstance(data, list):
data = [d for d in data if getattr(d, self.child.Meta.model.get_space_key()[0]) == self.context['request'].space]
else:

View File

@@ -174,6 +174,7 @@ const isShoppingLineDelayed = computed(() => {
function categoryUpdate(category: SupermarketCategory) {
const api = new ApiApi()
shoppingListFood.value.food.supermarketCategory = category
shoppingListFood.value.entries.forEach(e => e.food.supermarketCategory = category)
useShoppingStore().updateEntriesStructure()
api.apiFoodUpdate({id: shoppingListFood.value.food.id, food: shoppingListFood.value.food}).then(r => {
useMessageStore().addPreparedMessage(PreparedMessage.UPDATE_SUCCESS)

View File

@@ -234,6 +234,9 @@ export const useShoppingStore = defineStore(_STORE_ID, () => {
r.results.forEach((e) => {
entries.value.set(e.id!, e)
})
if(r.results.length > 0){
updateEntriesStructure()
}
currentlyUpdating.value = false
}).catch((err: any) => {
currentlyUpdating.value = false