mirror of
https://github.com/screentinker/screentinker.git
synced 2026-06-15 02:33:15 -06:00
Saving a layout grew its zone count on every server restart. Root cause: the editor saved zones with a per-zone delete-then-POST loop, and POST /zones minted a NEW uuid for every zone - so each save replaced the seeded ids (z-sh-1, ...) with fresh uuids. schema.sql re-seeds template zones via INSERT OR IGNORE on every boot, so the next restart re-added the now-missing canonical zone alongside the renamed copy -> a 2-zone template became 4, 6, ... (worse for self-hosters who rebuild often). Fix: - PUT /api/layouts/:id now accepts a zones[] and replaces them atomically in one transaction, REUSING each zone's id when supplied. The editor sends the full set in a single call, so the layout ends up with exactly those zones and ids stay stable (also fixes fit_mode not persisting, and stops device->zone assignments being orphaned by id churn). - One-time dedupe migration removes positional-duplicate template zones, keeping the canonical 'z-...' seeded id so the re-seed stays an idempotent no-op. Verified: 2 atomic saves keep count + ids stable with fit updated; dedupe restores a polluted 4-zone split template to its 2 canonical zones. Suite 56/56. |
||
|---|---|---|
| .. | ||
| database.js | ||
| schema.sql | ||