mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2025-12-06 00:20:05 +01:00
24 lines
577 B
TypeScript
24 lines
577 B
TypeScript
import { useProcesses } from "contexts/process";
|
|
import { createPid } from "contexts/process/functions";
|
|
import { useSession } from "contexts/session";
|
|
|
|
type UseFile = (pid: string) => void;
|
|
|
|
const useFile = (url: string): UseFile => {
|
|
const { setForegroundId } = useSession();
|
|
const { minimize, open, processes } = useProcesses();
|
|
|
|
return (pid: string) => {
|
|
const id = createPid(pid, url);
|
|
|
|
if (processes[id]) {
|
|
if (processes[id].minimized) minimize(id);
|
|
setForegroundId(id);
|
|
} else {
|
|
open(pid, url);
|
|
}
|
|
};
|
|
};
|
|
|
|
export default useFile;
|