fix(dashboard): filter todayMeals by visible_meal_types preference (#14)
The dashboard meal widget was showing all meal types regardless of the household meal visibility settings configured in Settings > Meal Plan. Root cause: the todayMeals SQL query in dashboard.js did not read visible_meal_types from sync_config. The Meals page applied this filter client-side, but the dashboard API returned unfiltered data. Fix: read visible_meal_types from sync_config before the query and inject the active types as IN (?) placeholders. Falls back to all four types when no preference is stored.
This commit is contained in:
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.11.1] - 2026-04-05
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fix dashboard meal widget ignoring meal type visibility settings - todayMeals query now reads visible_meal_types from sync_config and filters accordingly, consistent with the Meals page (#14)
|
||||||
|
|
||||||
## [0.11.0] - 2026-04-05
|
## [0.11.0] - 2026-04-05
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "oikos",
|
"name": "oikos",
|
||||||
"version": "0.11.0",
|
"version": "0.11.1",
|
||||||
"description": "Self-hosted family planner - calendar, tasks, shopping, meal planning, budget and more. Private, open-source, no subscription.",
|
"description": "Self-hosted family planner - calendar, tasks, shopping, meal planning, budget and more. Private, open-source, no subscription.",
|
||||||
"main": "server/index.js",
|
"main": "server/index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -80,11 +80,18 @@ router.get('/', (req, res) => {
|
|||||||
result.urgentTasks = [];
|
result.urgentTasks = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Heutiges Essen
|
// Heutiges Essen (gefiltert nach haushaltweiten Mahlzeit-Typ-Einstellungen)
|
||||||
try {
|
try {
|
||||||
|
const ALL_MEAL_TYPES = ['breakfast', 'lunch', 'dinner', 'snack'];
|
||||||
|
const prefRow = d.prepare('SELECT value FROM sync_config WHERE key = ?').get('visible_meal_types');
|
||||||
|
const visibleTypes = prefRow
|
||||||
|
? prefRow.value.split(',').filter((t) => ALL_MEAL_TYPES.includes(t))
|
||||||
|
: ALL_MEAL_TYPES;
|
||||||
|
const placeholders = visibleTypes.map(() => '?').join(', ');
|
||||||
result.todayMeals = d.prepare(`
|
result.todayMeals = d.prepare(`
|
||||||
SELECT * FROM meals
|
SELECT * FROM meals
|
||||||
WHERE date = ?
|
WHERE date = ?
|
||||||
|
AND meal_type IN (${placeholders})
|
||||||
ORDER BY
|
ORDER BY
|
||||||
CASE meal_type
|
CASE meal_type
|
||||||
WHEN 'breakfast' THEN 0
|
WHEN 'breakfast' THEN 0
|
||||||
@@ -92,7 +99,7 @@ router.get('/', (req, res) => {
|
|||||||
WHEN 'dinner' THEN 2
|
WHEN 'dinner' THEN 2
|
||||||
WHEN 'snack' THEN 3
|
WHEN 'snack' THEN 3
|
||||||
END
|
END
|
||||||
`).all(todayStr);
|
`).all(todayStr, ...visibleTypes);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log.error('todayMeals-Fehler:', err.message);
|
log.error('todayMeals-Fehler:', err.message);
|
||||||
result.todayMeals = [];
|
result.todayMeals = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user