From df0a47e336bf74ba7ceb10674634dc16312f3996 Mon Sep 17 00:00:00 2001 From: morgane Date: Wed, 17 Jun 2026 12:40:27 +0000 Subject: [PATCH] Actualiser assets/js/app.js --- assets/js/app.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/assets/js/app.js b/assets/js/app.js index b8e2d55..4829030 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1333,12 +1333,25 @@ function _showExportModal() { document.getElementById('modal-overlay').style.display = 'flex'; } -const LOCATIONS = { +let LOCATIONS = { 'dispensa': { icon: '🗄️', label: t('locations.dispensa') }, 'frigo': { icon: '🧊', label: t('locations.frigo') }, 'freezer': { icon: '❄️', label: t('locations.freezer') }, 'altro': { icon: '📦', label: t('locations.altro') }, }; +async function loadCustomLocations() { + try { + const result = await api('locations_list', {}, 'GET'); + if (result.success && Array.isArray(result.locations)) { + result.locations.forEach(loc => { + if (loc.is_builtin) return; // built-ins already have translated labels above + LOCATIONS[loc.key] = { icon: loc.icon || '📦', label: loc.label }; + }); + } + } catch (e) { + console.warn('[EverShelf] Could not load custom locations:', e); + } +} const CATEGORY_ICONS = { 'latticini': '🥛', 'carne': '🥩', 'pesce': '🐟', 'frutta': '🍎', 'verdura': '🥬', 'pasta': '🍝', 'pane': '🍞', 'surgelati': '🧊', @@ -19524,11 +19537,15 @@ function startHeartbeat() { _runHeartbeat(); // immediate first probe } + async function _initApp() { // ── Startup health check (runs during splash, blocks app if critical) ────── const _startupOk = await _runStartupCheck(); if (!_startupOk) return; // preloader stays visible with error; app does not start + // Load custom locations (merges into LOCATIONS before any UI renders) + await loadCustomLocations(); + // Check for setup wizard resume (after language change) const resumeStep = localStorage.getItem('evershelf_setup_step'); const resumeData = localStorage.getItem('evershelf_setup_data');