From c934bfb7b383fa1b3014372640312a0dd93fac46 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Mon, 26 Dec 2022 20:22:38 +0100 Subject: [PATCH] Refresh product/chore/battery card only when actually visible --- public/viewjs/components/batterycard.js | 5 +++++ public/viewjs/components/chorecard.js | 5 +++++ public/viewjs/components/productcard.js | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/public/viewjs/components/batterycard.js b/public/viewjs/components/batterycard.js index 6533628d..a0626745 100644 --- a/public/viewjs/components/batterycard.js +++ b/public/viewjs/components/batterycard.js @@ -2,6 +2,11 @@ Grocy.Components.BatteryCard = {}; Grocy.Components.BatteryCard.Refresh = function(batteryId) { + if (!$(".batterycard").is(":visible")) + { + return; + } + Grocy.Api.Get('batteries/' + batteryId, function(batteryDetails) { diff --git a/public/viewjs/components/chorecard.js b/public/viewjs/components/chorecard.js index ca4a38a1..4ccecf1d 100644 --- a/public/viewjs/components/chorecard.js +++ b/public/viewjs/components/chorecard.js @@ -2,6 +2,11 @@ Grocy.Components.ChoreCard = {}; Grocy.Components.ChoreCard.Refresh = function(choreId) { + if (!$(".chorecard").is(":visible")) + { + return; + } + Grocy.Api.Get('chores/' + choreId, function(choreDetails) { diff --git a/public/viewjs/components/productcard.js b/public/viewjs/components/productcard.js index dba979cc..8adf1e74 100644 --- a/public/viewjs/components/productcard.js +++ b/public/viewjs/components/productcard.js @@ -2,6 +2,11 @@ Grocy.Components.ProductCard = {}; Grocy.Components.ProductCard.Refresh = function(productId) { + if (!$(".productcard").is(":visible")) + { + return; + } + Grocy.Api.Get('stock/products/' + productId, function(productDetails) {