mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 02:08:57 +00:00
[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:
@@ -328,7 +328,6 @@ export function MediaEditor({
|
|||||||
width: img.width,
|
width: img.width,
|
||||||
};
|
};
|
||||||
setImageState(newImageState);
|
setImageState(newImageState);
|
||||||
takeSnapshot('initial state', newImageState, canvas);
|
|
||||||
};
|
};
|
||||||
img.onerror = (
|
img.onerror = (
|
||||||
event: Event | string,
|
event: Event | string,
|
||||||
@@ -591,6 +590,20 @@ export function MediaEditor({
|
|||||||
drawFabricBackgroundImage({ fabricCanvas, image, imageState });
|
drawFabricBackgroundImage({ fabricCanvas, image, imageState });
|
||||||
}, [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 [canCrop, setCanCrop] = useState(false);
|
||||||
const [cropAspectRatioLock, setCropAspectRatioLock] = useState(false);
|
const [cropAspectRatioLock, setCropAspectRatioLock] = useState(false);
|
||||||
const [drawTool, setDrawTool] = useState<DrawTool>(DrawTool.Pen);
|
const [drawTool, setDrawTool] = useState<DrawTool>(DrawTool.Pen);
|
||||||
|
|||||||
@@ -1456,6 +1456,14 @@
|
|||||||
"updated": "2025-05-19T22:29:15.758Z",
|
"updated": "2025-05-19T22:29:15.758Z",
|
||||||
"reasonDetail": "Holding on to a close function"
|
"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",
|
"rule": "React-useRef",
|
||||||
"path": "ts/components/MediaQualitySelector.dom.tsx",
|
"path": "ts/components/MediaQualitySelector.dom.tsx",
|
||||||
|
|||||||
Reference in New Issue
Block a user