[signalapp/Signal-Desktop#7526] Image disappears after first undo in media editor

Co-authored-by: HreshchyshynT <hreshchyshyn.t@gmail.com>
This commit is contained in:
automated-signal
2025-11-19 17:12:45 -06:00
committed by GitHub
parent 75870a885a
commit e3ad38bde1
2 changed files with 22 additions and 1 deletions

View File

@@ -328,7 +328,6 @@ export function MediaEditor({
width: img.width,
};
setImageState(newImageState);
takeSnapshot('initial state', newImageState, canvas);
};
img.onerror = (
event: Event | string,
@@ -591,6 +590,20 @@ export function MediaEditor({
drawFabricBackgroundImage({ fabricCanvas, image, imageState });
}, [fabricCanvas, image, imageState]);
const initialSnapshotTaken = useRef(false);
useEffect(() => {
if (
!fabricCanvas ||
!fabricCanvas.backgroundImage ||
initialSnapshotTaken.current
) {
return;
}
takeSnapshot('initial state', imageState, fabricCanvas);
initialSnapshotTaken.current = true;
}, [fabricCanvas, imageState, takeSnapshot]);
const [canCrop, setCanCrop] = useState(false);
const [cropAspectRatioLock, setCropAspectRatioLock] = useState(false);
const [drawTool, setDrawTool] = useState<DrawTool>(DrawTool.Pen);

View File

@@ -1456,6 +1456,14 @@
"updated": "2025-05-19T22:29:15.758Z",
"reasonDetail": "Holding on to a close function"
},
{
"rule": "React-useRef",
"path": "ts/components/MediaEditor.dom.tsx",
"line": " const initialSnapshotTaken = useRef(false);",
"reasonCategory": "usageTrusted",
"updated": "2025-11-19T18:44:48.727Z",
"reasonDetail": "Tracking whether initial snapshot has been taken"
},
{
"rule": "React-useRef",
"path": "ts/components/MediaQualitySelector.dom.tsx",