fix(frontend): resolve duplicated subscriber issue

This commit is contained in:
yassinedorbozgithub 2025-05-30 06:55:19 +01:00
parent 2594434137
commit a5ad31bd2e

View File

@ -9,7 +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 { useRouter } from "next/router"; import { useRouter } from "next/router";
import { useEffect, useState } from "react"; import { useMemo } from "react";
import { getAvatarSrc } from "@/components/inbox/helpers/mapMessages"; import { getAvatarSrc } from "@/components/inbox/helpers/mapMessages";
import { useAuth } from "@/hooks/useAuth"; import { useAuth } from "@/hooks/useAuth";
@ -17,7 +17,6 @@ import { useConfig } from "@/hooks/useConfig";
import { useSetting } from "@/hooks/useSetting"; import { useSetting } from "@/hooks/useSetting";
import i18n from "@/i18n/config"; import i18n from "@/i18n/config";
import { EntityType, RouterType } from "@/services/types"; import { EntityType, RouterType } from "@/services/types";
import { generateId } from "@/utils/generateId";
import { ChatWidgetHeader } from "./ChatWidgetHeader"; import { ChatWidgetHeader } from "./ChatWidgetHeader";
@ -30,11 +29,10 @@ export const ChatWidget = () => {
const isVisualEditor = pathname.startsWith(`/${RouterType.VISUAL_EDITOR}`); const isVisualEditor = pathname.startsWith(`/${RouterType.VISUAL_EDITOR}`);
const allowedDomainsSetting = useSetting(SETTING_TYPE, "allowed_domains"); const allowedDomainsSetting = useSetting(SETTING_TYPE, "allowed_domains");
const themeColorSetting = useSetting(SETTING_TYPE, "theme_color"); const themeColorSetting = useSetting(SETTING_TYPE, "theme_color");
const [key, setKey] = useState(generateId()); const key = useMemo(
() => `${allowedDomainsSetting}_${themeColorSetting}`,
useEffect(() => { [allowedDomainsSetting, themeColorSetting],
setKey(generateId()); );
}, [allowedDomainsSetting, themeColorSetting]);
return isAuthenticated ? ( return isAuthenticated ? (
<Box <Box