fix: update the logic to use useMemo

This commit is contained in:
yassinedorbozgithub 2024-12-04 17:12:39 +01:00
parent eb38675ded
commit b8033acf4c

View File

@ -9,6 +9,7 @@
import { Avatar, Box } from "@mui/material"; import { Avatar, Box } from "@mui/material";
import UiChatWidget from "hexabot-chat-widget/src/UiChatWidget"; import UiChatWidget from "hexabot-chat-widget/src/UiChatWidget";
import { usePathname } from "next/navigation"; import { usePathname } from "next/navigation";
import { useMemo } from "react";
import { getAvatarSrc } from "@/components/inbox/helpers/mapMessages"; import { getAvatarSrc } from "@/components/inbox/helpers/mapMessages";
import { useLoadSettings } from "@/hooks/entities/auth-hooks"; import { useLoadSettings } from "@/hooks/entities/auth-hooks";
@ -25,9 +26,14 @@ export const ChatWidget = () => {
const { isAuthenticated } = useAuth(); const { isAuthenticated } = useAuth();
const isVisualEditor = pathname === `/${RouterType.VISUAL_EDITOR}`; const isVisualEditor = pathname === `/${RouterType.VISUAL_EDITOR}`;
const { data: settings } = useLoadSettings(); const { data: settings } = useLoadSettings();
const key = JSON.stringify( const key = useMemo(
settings?.["console_channel"]?.find((s) => s.label === "allowed_domains") () =>
?.value, JSON.stringify(
settings?.["console_channel"]?.find(
(s) => s.label === "allowed_domains",
)?.value,
),
[settings],
); );
return isAuthenticated ? ( return isAuthenticated ? (