mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 22:26:13 +00:00
fix(settings): make delegated module rows read-only managed deep-links
The Module hub rendered live switches for the delegated keys cycle and coach, but the gate resolves those from their own sources (cycle from CycleProfile, coach from the operator flag + disableCoach), so a toggle wrote an inert entry to modulePreferencesJson, snapped back, and still fired a success toast. Render delegated modules as read-only rows that deep-link to their real control, strip delegated keys from the modules PATCH schema so no inert value is stored, drop the duplicate cycle control, and surface an operator-disabled state with the previously orphaned hint string.
This commit is contained in:
1 parent
7c8d82f565
commit
91d01d154a
14 files changed
+216
-36
No files matched your search
@@ -95,6 +95,17 @@ export interface AuthUser {
|
||||
* absent), so live code reads a real map.
|
||||
*/
|
||||
modules?: Partial<Record<ModuleKey, boolean>>;
|
||||
/**
|
||||
* v1.18.0 — operator-layer availability per toggleable module. `false`
|
||||
* ⇒ the operator disabled the module server-wide (off for every account,
|
||||
* regardless of personal preference). Distinct from `modules`, which is
|
||||
* the already-AND-ed effective state and cannot tell operator-off from
|
||||
* user-off apart. Only the Modules hub needs this distinction (to render
|
||||
* an operator-disabled module as a read-only "disabled server-wide" row);
|
||||
* every other gate reads `modules`. Coerced to `{}` against a stale /me
|
||||
* payload so a missing map reads as all-available.
|
||||
*/
|
||||
moduleAvailability?: Partial<Record<ModuleKey, boolean>>;
|
||||
}
|
||||
|
||||
async function fetchMe(): Promise<AuthUser> {
|
||||
@@ -137,6 +148,13 @@ async function fetchMe(): Promise<AuthUser> {
|
||||
// open: a missing key reads as enabled and the nav stays intact.
|
||||
modules:
|
||||
data.modules && typeof data.modules === "object" ? data.modules : {},
|
||||
// v1.18.0 — operator availability map, coerced against a stale payload
|
||||
// to an empty map (all-available) so the Modules hub never shows a
|
||||
// spurious "disabled server-wide" row on an older server image.
|
||||
moduleAvailability:
|
||||
data.moduleAvailability && typeof data.moduleAvailability === "object"
|
||||
? data.moduleAvailability
|
||||
: {},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user