library: count a frame once when the read-back beats the handover
A reading this window holds hands each frame over the side as it stores it, and the screen puts those rows into the strip on a half-second debounce. The reading ends before that debounce fires, the screen reads the catalogue back — and that read already carries the frames that were handed over, so the rows still waiting are appended to a strip that has them: five files of a plain JPEG folder read "10 photos", the album row read 10, and the strip drew two tiles for every frame, one of them keyed the same as the other. Measured on five JPEGs: header 10, album row 10, ten tiles of five ids. The store held five rows and the reading reported 5/5 new frames the whole time, so the count was the screen's alone. A second pass over the same folder read five, because its read-back landed last. The id is the frame, so the append now skips what the strip already has. Same folder after: 5 photos, album row 5, five tiles of five ids, and no duplicate-key warning from React. Six RAW bodies and the studio are untouched: the fix is inside the catalogue screen's own row append.
This commit is contained in:
@@ -519,7 +519,17 @@ function Catalogue() {
|
||||
if (pendingRows.length > 0) {
|
||||
const toAdd = pendingRows;
|
||||
pendingRows = [];
|
||||
setPhotos((prev) => [...prev, ...toAdd]);
|
||||
// A frame handed over the side is a frame the read-back that landed beside
|
||||
// it already carries: a reading this window holds ends, the screen reads
|
||||
// the catalogue back, and the rows it was handed are still waiting out
|
||||
// their half second — so the same frame arrives twice and the header
|
||||
// counts it twice. The id is the frame, so one of it in the strip is
|
||||
// enough.
|
||||
setPhotos((prev) => {
|
||||
const have = new Set(prev.map((p) => p.id));
|
||||
const landed = toAdd.filter((p) => !have.has(p.id));
|
||||
return landed.length ? [...prev, ...landed] : prev;
|
||||
});
|
||||
}
|
||||
updateTimer = null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user