securityos/components/system/Window/RndWindow/useMinMaxRef.ts

17 lines
523 B
TypeScript
Raw Normal View History

2024-09-06 15:32:35 +00:00
import { useProcesses } from "contexts/process";
import { useEffect, useRef } from "react";
const useMinMaxRef = (id: string): React.MutableRefObject<boolean> => {
const { processes } = useProcesses();
const { maximized = false, minimized = false } = processes[id] || {};
const blockAutoPositionRef = useRef(false);
useEffect(() => {
blockAutoPositionRef.current = Boolean(maximized || minimized);
}, [maximized, minimized]);
return blockAutoPositionRef;
};
export default useMinMaxRef;