diff --git a/www/js/home.js b/www/js/home.js index c322bfe..ec2c12a 100644 --- a/www/js/home.js +++ b/www/js/home.js @@ -90,10 +90,12 @@ function scanCode() { } function openPlace(id, name) { + var placepopupnonce = Math.random(); $("#place-info").addClass("display-none"); $("#place-error-msg").addClass("display-none"); $("#place-popup .preloader").removeClass("display-none"); $("#place-popup").data("placeid", id); + $("#place-popup").data("placepopupnonce", placepopupnonce); $("#place-title").text(name); app.popup.open("#place-popup"); @@ -107,6 +109,14 @@ function openPlace(id, name) { }); var refreshPlaceStats = function () { + if (id != $("#place-popup").data("placeid")) { + console.log("refreshPlaceStats: place ID changed, stopping refresh"); + return; + } + if (placepopupnonce != $("#place-popup").data("placepopupnonce")) { + console.log("refreshPlaceStats: placepopupnonce changed, stopping redundant refresh"); + return; + } if (app.popup.get("#place-popup").opened) { updatePlaceStats(id); setTimeout(refreshPlaceStats, 2000);