daedalOS/components/system/Taskbar/AI/AIButton.tsx
Dustin Brett 24c17c0088
Some checks failed
Tests / tests (push) Has been cancelled
Add memo to everything
2025-07-01 09:10:22 -07:00

37 lines
1.1 KiB
TypeScript

import { memo } from "react";
import { importAIChat } from "components/system/Taskbar/functions";
import { AIIcon } from "components/system/Taskbar/AI/icons";
import StyledAIButton from "components/system/Taskbar/AI/StyledAIButton";
import { AI_TITLE, AI_WINDOW_ID, DIV_BUTTON_PROPS } from "utils/constants";
import { label } from "utils/functions";
import useTaskbarContextMenu from "components/system/Taskbar/useTaskbarContextMenu";
import { useSession } from "contexts/session";
import { useMenuPreload } from "hooks/useMenuPreload";
type AIButtonProps = {
aiVisible: boolean;
toggleAI: () => void;
};
const AIButton: FC<AIButtonProps> = ({ aiVisible, toggleAI }) => {
const menuPreloadHandler = useMenuPreload(importAIChat);
const { removeFromStack } = useSession();
return (
<StyledAIButton
onClick={() => {
toggleAI();
if (aiVisible) removeFromStack(AI_WINDOW_ID);
}}
{...DIV_BUTTON_PROPS}
{...label(AI_TITLE)}
{...useTaskbarContextMenu()}
{...menuPreloadHandler}
>
<AIIcon />
</StyledAIButton>
);
};
export default memo(AIButton);