refactor(mascot): simplify chat visibility logic and add persistent chat mode

This commit is contained in:
MythEclipse
2026-06-03 15:08:31 +07:00
parent 7904d7f38d
commit f303b04684
2 changed files with 11 additions and 11 deletions
@@ -13,6 +13,7 @@ interface MascotImageProps {
className?: string;
showChat?: boolean;
chatMessage?: string;
persistChat?: boolean;
}
const sizeMap = {
@@ -32,6 +33,7 @@ export function MascotImage({
className = "",
showChat = false,
chatMessage = "",
persistChat = false,
}: MascotImageProps) {
const sizeClass = sizeMap[size];
const chatSizeClass = chatSizeMap[size];
@@ -40,10 +42,12 @@ export function MascotImage({
useEffect(() => {
if (showChat && chatMessage) {
setIsVisible(true);
if (persistChat) return;
const timer = setTimeout(() => setIsVisible(false), 8000); // Auto hide after 8s
return () => clearTimeout(timer);
}
}, [showChat, chatMessage]);
setIsVisible(false);
}, [showChat, chatMessage, persistChat]);
return (
<div className="relative inline-block">