Миграции, сборка

This commit is contained in:
Халимов Рустам
2026-03-27 23:09:16 +03:00
parent 030ae1e4e4
commit ba5c5210d4
43 changed files with 406 additions and 194 deletions

View File

@@ -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>
))}