Feature/301 rotate photos #303
@@ -86,6 +86,15 @@ function DraftPhoto({
|
|||||||
// session asks it to. This is what makes the button visibly do something. No
|
// session asks it to. This is what makes the button visibly do something. No
|
||||||
// column and no server change: the file's identity has not changed, only this
|
// column and no server change: the file's identity has not changed, only this
|
||||||
// page's need to see it again.
|
// page's need to see it again.
|
||||||
|
//
|
||||||
|
// Bumped in `finally`, not on success, and that is the whole point of it
|
||||||
|
// rather than a tidy-up. The server turns the displayed file first and the
|
||||||
|
// pristine original second, so a failure between them answers 500 with the
|
||||||
|
// photo already rotated on disk. Bumping only on success would show that
|
||||||
|
// admin an error beside a picture that had not visibly moved, and the
|
||||||
|
// obvious response — press it again — turns it a second time. Re-requesting
|
||||||
|
// the file either way is what makes the design's remedy, one press back,
|
||||||
|
// actually available. The cost is one wasted request when nothing changed.
|
||||||
const [version, setVersion] = useState(0);
|
const [version, setVersion] = useState(0);
|
||||||
const src = version === 0 ? image.image_path : `${image.image_path}?v=${version}`;
|
const src = version === 0 ? image.image_path : `${image.image_path}?v=${version}`;
|
||||||
|
|
||||||
@@ -107,10 +116,10 @@ function DraftPhoto({
|
|||||||
setTurning(true);
|
setTurning(true);
|
||||||
try {
|
try {
|
||||||
await rotateImage(itemId, image.id, direction);
|
await rotateImage(itemId, image.id, direction);
|
||||||
setVersion(Date.now());
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
message.error(err instanceof Error ? err.message : 'that did not work');
|
message.error(err instanceof Error ? err.message : 'that did not work');
|
||||||
} finally {
|
} finally {
|
||||||
|
setVersion(Date.now());
|
||||||
setTurning(false);
|
setTurning(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user