From e2969c18378f91b893da48fe3695e276655860ed Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 3 Dec 2025 09:19:46 +0100 Subject: [PATCH] Enhance RevenueSection to conditionally load product prices based on currentRegionId - Updated watchers in RevenueSection to ensure product prices are only loaded when currentRegionId is not null. - Added a check in loadPricesForAllProducts to skip execution if currentRegionId is null or undefined, improving performance and preventing unnecessary calls. - Enhanced overall logic to ensure accurate price loading based on the selected region, contributing to a better user experience. --- frontend/src/components/falukant/RevenueSection.vue | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/falukant/RevenueSection.vue b/frontend/src/components/falukant/RevenueSection.vue index 2e98004..a09f197 100644 --- a/frontend/src/components/falukant/RevenueSection.vue +++ b/frontend/src/components/falukant/RevenueSection.vue @@ -78,17 +78,22 @@ }, watch: { isRevenueTableOpen(newVal) { - if (newVal) { + if (newVal && this.currentRegionId !== null) { this.loadPricesForAllProducts(); } }, products: { handler() { - if (this.isRevenueTableOpen) { + if (this.isRevenueTableOpen && this.currentRegionId !== null) { this.loadPricesForAllProducts(); } }, deep: true + }, + currentRegionId(newVal) { + if (this.isRevenueTableOpen && newVal !== null) { + this.loadPricesForAllProducts(); + } } }, methods: { @@ -99,6 +104,10 @@ } }, async loadPricesForAllProducts() { + if (this.currentRegionId === null || this.currentRegionId === undefined) { + console.log(`[RevenueSection] Skipping loadPricesForAllProducts - currentRegionId is null/undefined`); + return; + } console.log(`[RevenueSection] loadPricesForAllProducts called, products: ${this.products.length}, currentRegionId: ${this.currentRegionId}`); for (const product of this.products) { if (this.loadingPrices.has(product.id)) continue;