mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2025-12-06 12:20:20 +01:00
20 lines
521 B
TypeScript
20 lines
521 B
TypeScript
import { useMemo } from "react";
|
|
import { useProcesses } from "contexts/process";
|
|
import { useSession } from "contexts/session";
|
|
|
|
const useNextFocusable = (id: string): string => {
|
|
const { stackOrder = [] } = useSession();
|
|
const { processes } = useProcesses();
|
|
const nextFocusableId = useMemo(
|
|
() =>
|
|
stackOrder.find(
|
|
(stackId) => stackId !== id && !processes?.[stackId]?.minimized
|
|
),
|
|
[id, processes, stackOrder]
|
|
);
|
|
|
|
return nextFocusableId || "";
|
|
};
|
|
|
|
export default useNextFocusable;
|