diff --git a/src/components/chat/ChatWidget.tsx b/src/components/chat/ChatWidget.tsx
index f7d6c06..e53be4e 100644
--- a/src/components/chat/ChatWidget.tsx
+++ b/src/components/chat/ChatWidget.tsx
@@ -105,6 +105,24 @@ interface ToastNotif {
id: string; roomId: string; roomName: string; senderName: string; text: string
}
+function renderWithMentions(text: string, myName?: string) {
+ const parts = text.split(/(@\S+)/g)
+ if (parts.length === 1) return <>{text}>
+ const myFirst = myName?.split(' ')[0]?.toLowerCase()
+ return <>
+ {parts.map((part, i) => {
+ if (!part.startsWith('@')) return {part}
+ const mentioned = part.slice(1).toLowerCase()
+ const isMe = myFirst && mentioned.startsWith(myFirst)
+ return (
+
+ {part}
+
+ )
+ })}
+ >
+}
+
// ── Main ───────────────────────────────────────────────────────────────────
type View = 'rooms' | 'messages' | 'search' | 'settings'
@@ -204,7 +222,10 @@ export function ChatWidget() {
if (curr > prev) {
const isViewing = open && view === 'messages' && activeRoomIdRef.current === room.id
const isMuted = mutedIds.includes(room.id)
- if (!isViewing && !isMuted) {
+ // Bypass mute if current user is mentioned
+ const myFirst = (user as { name?: string } | null | undefined)?.name?.split(' ')[0]
+ const isMentioned = myFirst ? (room.lastMessage ?? '').includes(`@${myFirst}`) : false
+ if (!isViewing && (!isMuted || isMentioned)) {
if (settings.soundEnabled) playNotifSound()
if (settings.popupEnabled !== false) {
const rName = room.type === 'general' ? 'Общий чат'
@@ -318,17 +339,7 @@ export function ChatWidget() {
return () => window.removeEventListener('click', h)
}, [ctxMenu])
- // Close chat when clicking outside the widget
- useEffect(() => {
- if (!open) return
- const h = (e: MouseEvent) => {
- if (widgetRef.current && !widgetRef.current.contains(e.target as Node)) {
- setOpen(false)
- }
- }
- document.addEventListener('mousedown', h)
- return () => document.removeEventListener('mousedown', h)
- }, [open])
+ // close-on-outside handled by overlay div in JSX
// ── Typing helpers ────────────────────────────────────────────────────────
@@ -530,6 +541,8 @@ export function ChatWidget() {
return (
+ {/* Transparent overlay — closes chat when clicking outside panel */}
+ {open &&
setOpen(false)} />}
{/* Float button */}