fix: show price total on dashboard via sessionStorage fallback
This commit is contained in:
+18
-2
@@ -3206,6 +3206,8 @@ async function loadDashboard() {
|
||||
});
|
||||
// Load shopping list count from Bring!
|
||||
loadShoppingCount();
|
||||
// Show last known price total immediately from sessionStorage (before next background fetch)
|
||||
_updateDashboardPriceTotal();
|
||||
|
||||
// Quick recipe button - show when there are expiring products
|
||||
const recipeBar = document.getElementById('quick-recipe-bar');
|
||||
@@ -9233,7 +9235,10 @@ function _updateDashboardPriceTotal() {
|
||||
const el = document.getElementById('stat-price-total');
|
||||
if (!el) return;
|
||||
const s = getSettings();
|
||||
if (!s.price_enabled || !shoppingItems.length) { el.style.display = 'none'; return; }
|
||||
if (!s.price_enabled) { el.style.display = 'none'; return; }
|
||||
|
||||
// If shoppingItems are loaded, compute fresh total and persist it
|
||||
if (shoppingItems.length > 0) {
|
||||
const sym = _currencySymbol(s.price_currency || 'EUR');
|
||||
const items = _buildPricePayload();
|
||||
let total = 0, count = 0;
|
||||
@@ -9245,7 +9250,18 @@ function _updateDashboardPriceTotal() {
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
el.textContent = `ca. ${sym}${total.toFixed(2)}`;
|
||||
const text = `ca. ${sym}${total.toFixed(2)}`;
|
||||
el.textContent = text;
|
||||
el.style.display = '';
|
||||
try { sessionStorage.setItem('_pricetotal', text); } catch { /* quota */ }
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: restore last known total saved in sessionStorage (dashboard before visiting shopping tab)
|
||||
const saved = sessionStorage.getItem('_pricetotal');
|
||||
if (saved) {
|
||||
el.textContent = saved;
|
||||
el.style.display = '';
|
||||
} else {
|
||||
el.style.display = 'none';
|
||||
|
||||
+1
-1
@@ -1461,6 +1461,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="assets/js/app.js?v=20260507d"></script>
|
||||
<script src="assets/js/app.js?v=20260507e"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user