Миграции, сборка
This commit is contained in:
@@ -6,7 +6,7 @@ import { getSocket, disconnectSocket } from '../../../core/infrastructure/socket
|
||||
import { ChatApi } from '../infrastructure/chatApi';
|
||||
import { playNotificationSound, isChatMuted, playCallRingtone, stopCallRingtone } from '../../../core/utils/sounds';
|
||||
import { useLang } from '../../../core/infrastructure/i18n';
|
||||
import type { Message, UserBasic, CallInfo } from '../../../core/domain/types';
|
||||
import type { Message, UserBasic, CallInfo, ChatMember } from '../../../core/domain/types';
|
||||
import { Send, Check, Phone, PhoneOff } from 'lucide-react';
|
||||
import Sidebar from '../../../core/presentation/layouts/Sidebar';
|
||||
import ChatView from './components/ChatView';
|
||||
|
||||
@@ -32,19 +32,19 @@ function ChatListItem({ chat, isActive }: ChatListItemProps) {
|
||||
|
||||
const otherMember = chat.members.find((m) => m.user.id !== user?.id);
|
||||
const isFavorites = chat.type === 'favorites';
|
||||
const chatName = isFavorites
|
||||
const chatName = (isFavorites
|
||||
? t('favorites')
|
||||
: chat.type === 'personal'
|
||||
? otherMember?.user.displayName || otherMember?.user.userName || otherMember?.user.username || t('chat')
|
||||
: chat.name || t('group');
|
||||
: chat.name || t('group')) || '??';
|
||||
|
||||
const chatAvatar = isFavorites
|
||||
const chatAvatar: string | null = isFavorites
|
||||
? null
|
||||
: chat.type === 'personal'
|
||||
? otherMember?.user.avatarUrl || otherMember?.user.avatar
|
||||
: chat.avatarUrl || chat.avatar;
|
||||
? otherMember?.user.avatarUrl || otherMember?.user.avatar || null
|
||||
: chat.avatarUrl || chat.avatar || null;
|
||||
|
||||
const isOnline = chat.type === 'personal' && otherMember?.user.isOnline;
|
||||
const isOnline = chat.type === 'personal' && !!otherMember?.user.isOnline;
|
||||
|
||||
// Check if someone is typing in this chat
|
||||
const typingInChat = typingUsers.filter((t) => t.chatId === chat.id && t.userId !== user?.id);
|
||||
@@ -128,8 +128,9 @@ function ChatListItem({ chat, isActive }: ChatListItemProps) {
|
||||
} catch (e) { console.error(e); }
|
||||
};
|
||||
|
||||
const initials = chatName
|
||||
const initials = (chatName || '??')
|
||||
.split(' ')
|
||||
.filter(Boolean)
|
||||
.map((w: string) => w[0])
|
||||
.join('')
|
||||
.slice(0, 2)
|
||||
@@ -151,7 +152,7 @@ function ChatListItem({ chat, isActive }: ChatListItemProps) {
|
||||
<Bookmark size={22} className="text-white" />
|
||||
</div>
|
||||
) : (
|
||||
<Avatar src={chatAvatar} name={chatName} size="lg" online={isOnline ? true : undefined} />
|
||||
<Avatar src={chatAvatar || undefined} name={chatName || '??'} size="lg" online={isOnline ? true : false} />
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -93,13 +93,13 @@ export default function ChatView({ onStartCall, onStartGroupCall }: { onStartCal
|
||||
const chatName = isFavorites
|
||||
? t('favorites')
|
||||
: chat?.type === 'personal'
|
||||
? otherMember?.user.displayName || otherMember?.user.username || t('chat')
|
||||
? otherMember?.user.displayName || otherMember?.user.userName || otherMember?.user.username || t('chat')
|
||||
: chat?.name || t('group');
|
||||
const chatAvatar = isFavorites
|
||||
? null
|
||||
: chat?.type === 'personal'
|
||||
? otherMember?.user.avatar
|
||||
: chat?.avatar;
|
||||
? otherMember?.user.avatarUrl || otherMember?.user.avatar || null
|
||||
: chat?.avatarUrl || chat?.avatar || null;
|
||||
const isOnline = chat?.type === 'personal' && otherMember?.user.isOnline;
|
||||
|
||||
const typingInChat = typingUsers.filter((t) => t.chatId === activeChat && t.userId !== user?.id);
|
||||
@@ -422,7 +422,7 @@ export default function ChatView({ onStartCall, onStartGroupCall }: { onStartCal
|
||||
);
|
||||
}
|
||||
|
||||
const initials = chatName
|
||||
const initials = (chatName || '??')
|
||||
.split(' ')
|
||||
.map((w: string) => w[0])
|
||||
.join('')
|
||||
|
||||
@@ -151,10 +151,9 @@ function MessageBubble({
|
||||
};
|
||||
|
||||
const chatForDelete = chats.find(c => c.id === message.chatId);
|
||||
const otherMember = chatForDelete?.members.find(m => m.user.id !== user?.id);
|
||||
const otherMemberName = chatForDelete?.type === 'personal'
|
||||
? chatForDelete.members.find(m => m.user.id !== user?.id)?.user.displayName
|
||||
|| chatForDelete.members.find(m => m.user.id !== user?.id)?.user.username
|
||||
|| ''
|
||||
? otherMember?.user.displayName || otherMember?.user.userName || otherMember?.user.username || ''
|
||||
: '';
|
||||
|
||||
const isPinned = pinnedMessages[message.chatId]?.id === message.id;
|
||||
@@ -306,7 +305,7 @@ function MessageBubble({
|
||||
reactionGroups[r.emoji] = { count: 0, users: [], isMine: false, avatars: [] };
|
||||
}
|
||||
reactionGroups[r.emoji].count++;
|
||||
const displayName = r.user?.displayName || r.user?.username || '?';
|
||||
const displayName = r.user?.displayName || r.user?.userName || r.user?.username || '?';
|
||||
reactionGroups[r.emoji].users.push(displayName);
|
||||
if (reactionGroups[r.emoji].avatars.length < 3) {
|
||||
reactionGroups[r.emoji].avatars.push({
|
||||
@@ -318,8 +317,8 @@ function MessageBubble({
|
||||
if (r.userId === user?.id) reactionGroups[r.emoji].isMine = true;
|
||||
});
|
||||
|
||||
const senderName = message.sender?.displayName || message.sender?.username || '';
|
||||
const senderAvatar = message.sender?.avatar;
|
||||
const senderName = message.sender?.displayName || message.sender?.userName || message.sender?.username || '';
|
||||
const senderAvatar = message.sender?.avatarUrl || message.sender?.avatar;
|
||||
|
||||
const firstUrlMatch = message.content?.match(/https?:\/\/[^\s]+/);
|
||||
const firstUrl = firstUrlMatch ? firstUrlMatch[0] : null;
|
||||
@@ -453,7 +452,7 @@ function MessageBubble({
|
||||
}}
|
||||
>
|
||||
<p className={`text-[13.5px] font-semibold mb-0.5 truncate ${isMine ? 'text-white' : 'text-knot-500'}`}>
|
||||
{message.replyTo.sender?.displayName || message.replyTo.sender?.username}
|
||||
{message.replyTo.sender?.displayName || message.replyTo.sender?.userName || message.replyTo.sender?.username || ''}
|
||||
</p>
|
||||
<div className="flex items-center gap-1.5">
|
||||
{message.replyTo.isDeleted ? (
|
||||
@@ -536,7 +535,7 @@ function MessageBubble({
|
||||
onClick={() => onViewProfile?.(message.forwardedFromId!)}
|
||||
>
|
||||
<div className={`font-medium ${isMine ? 'text-white/90' : 'text-knot-500'}`}>
|
||||
{(t('forwardedFrom' as any) === 'forwardedFrom' ? 'Переслано от' : t('forwardedFrom' as any))} <span className="font-semibold">{message.forwardedFrom.displayName || message.forwardedFrom.username}</span>
|
||||
{(t('forwardedFrom' as any) === 'forwardedFrom' ? 'Переслано от' : t('forwardedFrom' as any))} <span className="font-semibold">{message.forwardedFrom.displayName || message.forwardedFrom.userName || message.forwardedFrom.username || ''}</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -22,7 +22,7 @@ import { useAuthStore } from '../../../auth/application/authStore';
|
||||
import { ChatApi } from '../../infrastructure/chatApi';
|
||||
import { getSocket } from '../../../../core/infrastructure/socket';
|
||||
import { useLang } from '../../../../core/infrastructure/i18n';
|
||||
import { AUDIO_EXTENSIONS, MAX_FILE_SIZE } from '../../../../core/domain/types';
|
||||
import { AUDIO_EXTENSIONS, MAX_FILE_SIZE, type ChatMember } from '../../../../core/domain/types';
|
||||
import { useNotificationStore } from '../../../../core/application/stores/notificationStore';
|
||||
import EmojiPicker from './EmojiPicker';
|
||||
|
||||
@@ -70,27 +70,31 @@ export default function MessageInput({ chatId }: MessageInputProps) {
|
||||
const filteredMembers = mentionQuery !== null && isGroup
|
||||
? chatMembers.filter((m) => {
|
||||
const q = mentionQuery.toLowerCase();
|
||||
return m.user.displayName.toLowerCase().includes(q) || m.user.username.toLowerCase().includes(q);
|
||||
return (m.user.displayName || '').toLowerCase().includes(q)
|
||||
|| (m.user.userName || '').toLowerCase().includes(q)
|
||||
|| (m.user.username || '').toLowerCase().includes(q);
|
||||
}).slice(0, 6)
|
||||
: [];
|
||||
|
||||
const insertMention = (member: { user: { username: string } }) => {
|
||||
const insertMention = (member: ChatMember) => {
|
||||
const el = inputRef.current;
|
||||
if (!el) return;
|
||||
const username = member.user.userName || member.user.username;
|
||||
if (!username) return;
|
||||
const cursorPos = el.selectionStart;
|
||||
const before = text.substring(0, cursorPos);
|
||||
const after = text.substring(cursorPos);
|
||||
// Find the @ that started this mention
|
||||
const atIdx = before.lastIndexOf('@');
|
||||
if (atIdx === -1) return;
|
||||
const newText = before.substring(0, atIdx) + `@${member.user.username} ` + after;
|
||||
const newText = before.substring(0, atIdx) + `@${username} ` + after;
|
||||
setText(newText);
|
||||
setDraft(chatId, newText);
|
||||
setMentionQuery(null);
|
||||
setMentionIndex(0);
|
||||
setTimeout(() => {
|
||||
el.focus();
|
||||
const newPos = atIdx + member.user.username.length + 2;
|
||||
const newPos = atIdx + username.length + 2;
|
||||
el.setSelectionRange(newPos, newPos);
|
||||
}, 0);
|
||||
};
|
||||
@@ -617,7 +621,7 @@ export default function MessageInput({ chatId }: MessageInputProps) {
|
||||
<p className="text-xs font-semibold text-knot-400 mb-0.5">
|
||||
{editingMessage
|
||||
? t('editing')
|
||||
: `${t('replyTo')} ${replyTo?.sender?.displayName || replyTo?.sender?.username || ''}`}
|
||||
: `${t('replyTo')} ${replyTo?.sender?.displayName || replyTo?.sender?.userName || replyTo?.sender?.username || ''}`}
|
||||
</p>
|
||||
<div className="text-xs text-zinc-300 truncate opacity-80 border-l border-white/20 pl-2 ml-1">
|
||||
{replyTo?.quote ? `«${replyTo.quote}»` : (editingMessage || replyTo)?.content || t('media') || 'Медиа'}
|
||||
@@ -813,16 +817,16 @@ export default function MessageInput({ chatId }: MessageInputProps) {
|
||||
i === mentionIndex ? 'bg-accent/20 text-white' : 'text-zinc-300 hover:bg-white/5'
|
||||
}`}
|
||||
>
|
||||
{m.user.avatar ? (
|
||||
<img src={m.user.avatar} className="w-7 h-7 rounded-full object-cover" alt="" />
|
||||
{m.user.avatarUrl || m.user.avatar ? (
|
||||
<img src={m.user.avatarUrl || m.user.avatar || ''} className="w-7 h-7 rounded-full object-cover" alt="" />
|
||||
) : (
|
||||
<div className="w-7 h-7 rounded-full bg-gradient-to-br from-knot-500 to-purple-600 flex items-center justify-center text-white text-xs font-semibold">
|
||||
{(m.user.displayName || m.user.username)[0]?.toUpperCase()}
|
||||
{(m.user.displayName || m.user.userName || m.user.username || '?')[0]?.toUpperCase()}
|
||||
</div>
|
||||
)}
|
||||
<div className="min-w-0">
|
||||
<p className="text-sm font-medium truncate">{m.user.displayName || m.user.username}</p>
|
||||
<p className="text-xs text-zinc-500 truncate">@{m.user.username}</p>
|
||||
<p className="text-sm font-medium truncate">{m.user.displayName || m.user.userName || m.user.username || '??'}</p>
|
||||
<p className="text-xs text-zinc-500 truncate">@{m.user.userName || m.user.username || '??'}</p>
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
|
||||
@@ -171,10 +171,10 @@ export default function NewChatModal({ onClose }: NewChatModalProps) {
|
||||
<img src={u.avatar} alt="" className="w-5 h-5 rounded-full object-cover" />
|
||||
) : (
|
||||
<div className="w-5 h-5 rounded-full bg-gradient-to-br from-knot-500 to-purple-600 flex items-center justify-center text-white text-[9px] font-semibold">
|
||||
{(u.displayName || u.username)?.[0]?.toUpperCase()}
|
||||
{(u.displayName || u.userName || u.username || '?')[0]?.toUpperCase()}
|
||||
</div>
|
||||
)}
|
||||
<span className="text-xs text-white">{u.displayName || u.username}</span>
|
||||
<span className="text-xs text-white">{u.displayName || u.userName || u.username || ''}</span>
|
||||
<button
|
||||
onClick={() => setSelectedUsers((prev) => prev.filter((p) => p.id !== u.id))}
|
||||
className="text-zinc-500 hover:text-zinc-300"
|
||||
@@ -230,7 +230,7 @@ export default function NewChatModal({ onClose }: NewChatModalProps) {
|
||||
onClick={() => setSelectedUsers((prev) => prev.filter((p) => p.id !== u.id))}
|
||||
className="flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-knot-500/20 border border-knot-500/30 text-xs text-white hover:bg-knot-500/30 transition-colors"
|
||||
>
|
||||
{(u.displayName || u.username)}
|
||||
{(u.displayName || u.userName || u.username || '')}
|
||||
<X size={11} />
|
||||
</button>
|
||||
))}
|
||||
@@ -276,7 +276,7 @@ export default function NewChatModal({ onClose }: NewChatModalProps) {
|
||||
<img src={u.avatar} alt="" className="w-10 h-10 rounded-full object-cover" />
|
||||
) : (
|
||||
<div className="w-10 h-10 rounded-full bg-gradient-to-br from-knot-500 to-purple-600 flex items-center justify-center text-white font-semibold text-sm">
|
||||
{(u.displayName || u.username)?.[0]?.toUpperCase() || '?'}
|
||||
{(u.displayName || u.userName || u.username || '?')[0]?.toUpperCase() || '?'}
|
||||
</div>
|
||||
)}
|
||||
{u.isOnline && (
|
||||
@@ -285,9 +285,9 @@ export default function NewChatModal({ onClose }: NewChatModalProps) {
|
||||
</div>
|
||||
<div className="min-w-0 text-left flex-1">
|
||||
<p className="text-sm font-medium text-white truncate">
|
||||
{u.displayName || u.username}
|
||||
{u.displayName || u.userName || u.username || ''}
|
||||
</p>
|
||||
<p className="text-xs text-zinc-500 truncate">@{u.username}</p>
|
||||
<p className="text-xs text-zinc-500 truncate">@{u.userName || u.username || ''}</p>
|
||||
</div>
|
||||
{mode === 'group-select' && (
|
||||
<div className={`w-5 h-5 rounded-full border-2 flex items-center justify-center flex-shrink-0 transition-colors ${
|
||||
@@ -326,7 +326,7 @@ export default function NewChatModal({ onClose }: NewChatModalProps) {
|
||||
<img src={u.avatar} alt="" className="w-10 h-10 rounded-full object-cover" />
|
||||
) : (
|
||||
<div className="w-10 h-10 rounded-full bg-gradient-to-br from-knot-500 to-purple-600 flex items-center justify-center text-white font-semibold text-sm">
|
||||
{(u.displayName || u.username)?.[0]?.toUpperCase() || '?'}
|
||||
{(u.displayName || u.userName || u.username || '?')[0]?.toUpperCase() || '?'}
|
||||
</div>
|
||||
)}
|
||||
{u.isOnline && (
|
||||
@@ -335,9 +335,9 @@ export default function NewChatModal({ onClose }: NewChatModalProps) {
|
||||
</div>
|
||||
<div className="min-w-0 text-left flex-1">
|
||||
<p className="text-sm font-medium text-white truncate">
|
||||
{u.displayName || u.username}
|
||||
{u.displayName || u.userName || u.username || ''}
|
||||
</p>
|
||||
<p className="text-xs text-zinc-500 truncate">@{u.username}</p>
|
||||
<p className="text-xs text-zinc-500 truncate">@{u.userName || u.username || ''}</p>
|
||||
</div>
|
||||
{mode === 'group-select' && (
|
||||
<div className={`w-5 h-5 rounded-full border-2 flex items-center justify-center flex-shrink-0 transition-colors ${
|
||||
|
||||
Reference in New Issue
Block a user