mirror of
https://github.com/hexastack/hexabot
synced 2025-06-11 08:54:49 +00:00
Merge pull request #407 from Hexastack/406-bug-chat-console-settings-applied-without-refreshing-the-page
fix: apply chat console settings without refreshing the page
This commit is contained in:
commit
7f420ebb31
@ -9,20 +9,32 @@
|
|||||||
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 { useEffect, useState } 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";
|
||||||
import { useConfig } from "@/hooks/useConfig";
|
import { useConfig } from "@/hooks/useConfig";
|
||||||
|
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";
|
||||||
|
|
||||||
|
const SETTING_TYPE = "console_channel" as const;
|
||||||
|
|
||||||
export const ChatWidget = () => {
|
export const ChatWidget = () => {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const { apiUrl } = useConfig();
|
const { apiUrl } = useConfig();
|
||||||
const { isAuthenticated } = useAuth();
|
const { isAuthenticated } = useAuth();
|
||||||
const isVisualEditor = pathname === `/${RouterType.VISUAL_EDITOR}`;
|
const isVisualEditor = pathname === `/${RouterType.VISUAL_EDITOR}`;
|
||||||
|
const allowedDomainsSetting = useSetting(SETTING_TYPE, "allowed_domains");
|
||||||
|
const themeColorSetting = useSetting(SETTING_TYPE, "theme_color");
|
||||||
|
const [key, setKey] = useState(generateId());
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setKey(generateId());
|
||||||
|
}, [allowedDomainsSetting, themeColorSetting]);
|
||||||
|
|
||||||
return isAuthenticated ? (
|
return isAuthenticated ? (
|
||||||
<Box
|
<Box
|
||||||
@ -31,6 +43,7 @@ export const ChatWidget = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<UiChatWidget
|
<UiChatWidget
|
||||||
|
key={key}
|
||||||
config={{
|
config={{
|
||||||
apiUrl,
|
apiUrl,
|
||||||
channel: "console-channel",
|
channel: "console-channel",
|
||||||
|
Loading…
Reference in New Issue
Block a user