Fix mutated closedCurtains state in curtains.

This commit is contained in:
Madeorsk 2024-07-14 19:20:11 +02:00
parent f3c8a9858b
commit ed4e766650
Signed by: Madeorsk
SSH key fingerprint: SHA256:J9G0ofIOLKf7kyS2IfrMqtMaPdfsk1W02+oGueZzDDU

View file

@ -135,12 +135,13 @@ export function Curtains({children}: React.PropsWithChildren<{}>)
remove.current = useCallback((uuid: CurtainUuidType) => { remove.current = useCallback((uuid: CurtainUuidType) => {
// Copy the curtains list. // Copy the curtains list.
const newCurtains = {...curtains}; const newCurtains = {...curtains};
const newClosedCurtains = {...closedCurtains};
// Remove the given curtain from the list. // Remove the given curtain from the list.
delete newCurtains[uuid]; delete newCurtains[uuid];
delete closedCurtains[uuid]; delete newClosedCurtains[uuid];
// Set the new curtains list. // Set the new curtains list.
setCurtains(newCurtains); setCurtains(newCurtains);
setClosedCurtains(closedCurtains); setClosedCurtains(newClosedCurtains);
}, [curtains, setCurtains, closedCurtains, setClosedCurtains]); }, [curtains, setCurtains, closedCurtains, setClosedCurtains]);
// Initialize close curtain function with animation. // Initialize close curtain function with animation.