Редактирование и плеер
This commit is contained in:
@@ -148,8 +148,8 @@ export default function ChatPage() {
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('message_edited', (message: Message) => {
|
||||
updateMessage(message);
|
||||
socket.on('message_edited', (data: { messageId: string; chatId: string; content: string; isEdited: boolean }) => {
|
||||
updateMessage({ id: data.messageId, chatId: data.chatId, content: data.content, isEdited: data.isEdited } as Message);
|
||||
});
|
||||
|
||||
socket.on('new_chat', (chat: any) => {
|
||||
|
||||
@@ -25,13 +25,14 @@ import {
|
||||
PhoneIncoming,
|
||||
PhoneOutgoing,
|
||||
BarChart2,
|
||||
Music,
|
||||
} from 'lucide-react';
|
||||
import { useAuthStore } from '../../../auth/application/authStore';
|
||||
import { useChatStore } from '../../application/chatStore';
|
||||
import { getSocket } from '../../../../core/infrastructure/socket';
|
||||
import { useLang } from '../../../../core/infrastructure/i18n';
|
||||
import { extractWaveform, getMediaUrl, generateAvatarColor, getInitials } from '../../../../core/utils/utils';
|
||||
import type { Message, MediaItem, Reaction, ChatMember } from '../../../../core/domain/types';
|
||||
import { AUDIO_EXTENSIONS, type Message, type MediaItem, type Reaction, type ChatMember } from '../../../../core/domain/types';
|
||||
import ImageLightbox from '../../../../core/presentation/components/ui/ImageLightbox';
|
||||
import LinkPreview from './LinkPreview';
|
||||
import Avatar from '../../../../core/presentation/components/ui/Avatar';
|
||||
@@ -355,11 +356,13 @@ function MessageBubble({
|
||||
return false;
|
||||
};
|
||||
|
||||
const isAudioFile = (m: MediaItem) => m.type === 'audio' || AUDIO_EXTENSIONS.some(ext => m.filename?.toLowerCase().endsWith(ext));
|
||||
|
||||
const hasImage = media.some((m) => m.type === 'image' || isMediaGif(m));
|
||||
const hasVoice = message.type === 'voice' || media.some((m) => m.type === 'voice');
|
||||
const hasAudio = !hasVoice && (message.type === 'audio' || media.some((m) => m.type === 'audio'));
|
||||
const hasAudio = !hasVoice && (message.type === 'audio' || media.some(isAudioFile));
|
||||
const hasVideo = media.some((m) => m.type === 'video' && !isMediaGif(m));
|
||||
const hasFile = media.some((m) => m.type !== 'image' && m.type !== 'voice' && m.type !== 'video' && m.type !== 'audio' && !isMediaGif(m));
|
||||
const hasFile = media.some((m) => m.type !== 'image' && m.type !== 'voice' && m.type !== 'video' && !isAudioFile(m) && !isMediaGif(m));
|
||||
|
||||
const reactionGroups: Record<string, { count: number; users: string[]; isMine: boolean; avatars: { url?: string | null, initials: string, colorClass?: string }[] }> = {};
|
||||
(message.reactions || []).forEach((r) => {
|
||||
@@ -765,7 +768,7 @@ function MessageBubble({
|
||||
|
||||
{/* Аудио (mp3 файлы) */}
|
||||
{hasAudio && (() => {
|
||||
const audioMedia = media.find((m) => m.type === 'audio');
|
||||
const audioMedia = media.find(isAudioFile);
|
||||
const formatSize = (bytes?: number | null) => {
|
||||
if (!bytes) return "";
|
||||
if (bytes < 1024) return bytes + " B";
|
||||
@@ -855,7 +858,7 @@ function MessageBubble({
|
||||
{/* Файлы */}
|
||||
{hasFile &&
|
||||
media
|
||||
.filter((m) => m.type !== 'image' && m.type !== 'voice' && m.type !== 'video' && m.type !== 'audio' && m.type !== 'gif')
|
||||
.filter((m) => m.type !== 'image' && m.type !== 'voice' && m.type !== 'video' && !isAudioFile(m) && m.type !== 'gif')
|
||||
.map((m) => {
|
||||
const formatSize = (bytes?: number | null) => {
|
||||
if (!bytes) return "";
|
||||
|
||||
@@ -224,10 +224,15 @@ export default function MessageInput({ chatId }: MessageInputProps) {
|
||||
fileSize: res.size
|
||||
}));
|
||||
|
||||
let msgType = 'file';
|
||||
if (attachments.every(a => a.type === 'image')) msgType = 'image';
|
||||
else if (attachments.every(a => a.type === 'audio')) msgType = 'audio';
|
||||
else if (attachments.every(a => a.type === 'video')) msgType = 'video';
|
||||
|
||||
socket.emit('send_message', {
|
||||
chatId,
|
||||
content: trimmed || null,
|
||||
type: attachments.length > 0 ? (attachments.every(a => a.type === 'image') ? 'image' : 'file') : 'text',
|
||||
type: msgType,
|
||||
attachments: socketAttachments,
|
||||
replyToId: replyTo?.id || null,
|
||||
quote: replyTo?.quote || null,
|
||||
|
||||
Reference in New Issue
Block a user