(fp: ImageFilePair)
| 45 | |
| 46 | const [, forceUpdate] = React.useState(0); |
| 47 | const computePerceptualDiffBox = (fp: ImageFilePair) => { |
| 48 | if (!isSameSizeImagePair(fp)) return; |
| 49 | // TODO(danvk): restructure this, it's a mess |
| 50 | (async () => { |
| 51 | const response = await fetch(`/pdiffbbox/${fp.idx}`); |
| 52 | const bbox = (await response.json()) as DiffBox; |
| 53 | const {diffData} = fp; |
| 54 | // XXX are there other fields? |
| 55 | fp.diffData = { |
| 56 | ...diffData, |
| 57 | diffBounds: bbox, |
| 58 | }; |
| 59 | console.log('forcing update'); |
| 60 | forceUpdate(n => n + 1); // tell react about this change |
| 61 | })().catch((error: unknown) => { |
| 62 | console.error(error); |
| 63 | }); |
| 64 | }; |
| 65 | |
| 66 | if (pdiffMode === 'bbox' && !pair.diffData) { |
| 67 | // XXX this might shoot off unnecessary XHRs--use a Promise! |
no test coverage detected