mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 05:42:19 +00:00
fix(dashboard): hide a switched-off module's widgets on every feed
The dashboard widget and summary maps are now views of the surface map. The legacy dashboard feed painted the stored layout as saved, so the medications card stayed with the module off; the mask the snapshot applies now runs on that feed too, in the browser, from the same map. The widgets route keeps returning the stored layout unmasked, because Settings saves that value back. The Today digest is the day's data and no longer waits on the AI analysis switch, on the server prefetch or in the browser.
This commit is contained in:
1 parent
91be6b2967
commit
94e07d0d90
6 files changed
+130
-133
No files matched your search
@@ -53,10 +53,8 @@ import {
|
||||
import { apiDelete, apiGet, apiPut, ApiError } from "@/lib/api/api-fetch";
|
||||
import { useMounted } from "@/hooks/use-mounted";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import {
|
||||
NATIVE_ONLY_WIDGET_LABEL_KEYS,
|
||||
WIDGET_MODULE_BY_ID,
|
||||
} from "@/lib/dashboard/widget-modules";
|
||||
import { NATIVE_ONLY_WIDGET_LABEL_KEYS } from "@/lib/dashboard/widget-modules";
|
||||
import { isSurfaceVisible } from "@/lib/modules/surface";
|
||||
import { SettingsCard } from "@/components/settings/settings-card";
|
||||
import { SettingsCardHeader } from "@/components/settings/_card-header";
|
||||
|
||||
@@ -605,14 +603,10 @@ export function DashboardLayoutSection({ id }: { id: string }) {
|
||||
.filter((w): w is typeof w & { id: DashboardWidgetId } =>
|
||||
webWidgetIds.has(w.id),
|
||||
)
|
||||
// v1.18.0 — hide a widget toggle whose owning module is
|
||||
// disabled. Map the widget id → ModuleKey FIRST (undefined =
|
||||
// core widget = always shown), THEN check the module map.
|
||||
// Fail-open: only an explicit `false` hides the row.
|
||||
.filter((w) => {
|
||||
const moduleKey = WIDGET_MODULE_BY_ID[w.id];
|
||||
return !moduleKey || modules?.[moduleKey] !== false;
|
||||
})
|
||||
// Hide a widget toggle whose owning module is off, through the
|
||||
// one surface map. A core widget has no owner and always shows;
|
||||
// only an explicit `false` hides the row.
|
||||
.filter((w) => isSurfaceVisible(`widget:${w.id}`, modules))
|
||||
.filter((w) => !unavailableIds.has(w.id))
|
||||
.sort((a, b) => a.order - b.order);
|
||||
const sortedIds = sortedWidgets.map((w) => w.id);
|
||||
@@ -685,10 +679,7 @@ export function DashboardLayoutSection({ id }: { id: string }) {
|
||||
.filter((w) => nativeOnlyIds.has(w.id))
|
||||
// Same fail-open module gate as the web list: only an explicit
|
||||
// `false` hides the row.
|
||||
.filter((w) => {
|
||||
const moduleKey = WIDGET_MODULE_BY_ID[w.id];
|
||||
return !moduleKey || modules?.[moduleKey] !== false;
|
||||
})
|
||||
.filter((w) => isSurfaceVisible(`widget:${w.id}`, modules))
|
||||
.filter((w) => !unavailableIds.has(w.id))
|
||||
.sort((a, b) => a.order - b.order);
|
||||
if (nativeWidgets.length === 0) return null;
|
||||
|
||||
Reference in new issue
Block a user