fix(fe): make capture photo ids unique per slab

slab_photos.id is a global primary key, but photo ids were cap-<i>-<size> -
identical for the same photo set on a different slab, so the upload hit
UNIQUE constraint failed: slab_photos.id and returned 500. Key the id on the
slab id so it is unique across slabs.
This commit is contained in:
2026-09-25 20:33:39 -07:00
parent 23de433bdb
commit dfe192fa8a
+4 -2
View File
@@ -124,8 +124,10 @@
// processedBlob so the server upload carries real images (PUBLISH-40). // processedBlob so the server upload carries real images (PUBLISH-40).
const calIdx = s.calibrationIndex; const calIdx = s.calibrationIndex;
const apply = results?.batchApply; const apply = results?.batchApply;
// slab_photos.id is a global primary key, so the id must be unique
// across slabs - key it on the slab id, not just the index/size.
const photos = s.batch.map((source, i) => ({ const photos = s.batch.map((source, i) => ({
id: `cap-${i}-${source.blob.size}`, id: `cap-${d.id}-${i}`,
seq: i + 1, seq: i + 1,
isCalibration: i === calIdx, isCalibration: i === calIdx,
url: URL.createObjectURL(source.blob), url: URL.createObjectURL(source.blob),
@@ -144,7 +146,7 @@
// encode failed (known separate defect) — the lineup just shows no overlay. // encode failed (known separate defect) — the lineup just shows no overlay.
if (results?.overlayPng && calIdx != null) { if (results?.overlayPng && calIdx != null) {
const overlay = { const overlay = {
id: `overlay-${calIdx}-${results.overlayPng.size}`, id: `overlay-${d.id}-${calIdx}`,
seq: calIdx + 2, seq: calIdx + 2,
isCalibration: false, isCalibration: false,
url: URL.createObjectURL(results.overlayPng), url: URL.createObjectURL(results.overlayPng),