mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 06:32:03 +00:00
fix(insights): preserve stored layout dimension on a partial PUT
A PUT that omits sections (an iOS tiles-only reorder) reset the user's section customization to defaults, and symmetrically a sections-only PUT reset the stored tiles. serializeInsightsLayout now takes the resolved stored layout and falls back to it — not to defaults — for whichever dimension the body omits; the PUT handler loads the stored layout first. A first-ever single-dimension PUT (no stored layout) still fills defaults, so the v2 blob stays complete. Pins the merge behaviour with three unit cases.
This commit is contained in:
1 parent
7b0688b37e
commit
7fa10b43a0
3 files changed
+110
-9
No files matched your search
@@ -170,7 +170,12 @@ export const PUT = apiHandler(async (request: NextRequest) => {
|
||||
return returnAllZodIssues(parsed.error, 422);
|
||||
}
|
||||
|
||||
const normalized = serializeInsightsLayout(parsed.data);
|
||||
// v1.16.13 — load the user's stored layout so a PUT that omits a
|
||||
// dimension (iOS reorders tiles with a tiles-only body, no `sections`
|
||||
// key) preserves the other dimension's customization instead of
|
||||
// resetting it to defaults.
|
||||
const previous = await buildInsightsLayout(user.id);
|
||||
const normalized = serializeInsightsLayout(parsed.data, previous);
|
||||
|
||||
await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
|
||||
Reference in new issue
Block a user