From 01331d02634e01cc135cdf4a3d8d3807813ebc14 Mon Sep 17 00:00:00 2001 From: Ai Date: Fri, 22 May 2026 11:38:50 +0300 Subject: [PATCH] fix: error boundary, fix MessageInput import order, fix favicon SVG->PNG --- frontend/index.html | 2 +- frontend/src/App.tsx | 47 ++++++++++++++++++------- frontend/src/components/MessageList.tsx | 3 +- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index 87d78d8..513396f 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -2,7 +2,7 @@ - + diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 937a5b9..707a05e 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,5 +1,24 @@ -import { useEffect } from 'react'; +import { useEffect, Component, ReactNode } from 'react'; import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'; + +class ErrorBoundary extends Component<{ children: ReactNode }, { error: string | null }> { + state = { error: null }; + static getDerivedStateFromError(err: Error) { return { error: err.message }; } + render() { + if (this.state.error) { + return ( +
+

Ошибка приложения

+
{this.state.error}
+ +
+ ); + } + return this.props.children; + } +} import LoginPage from './pages/Login'; import MainLayout from './pages/MainLayout'; import { useStore } from './store'; @@ -79,17 +98,19 @@ export default function App() { } return ( - - - { - localStorage.setItem('jc_token', token); - localStorage.setItem('jc_user', JSON.stringify(user)); - setUser(user); - connectWS(token); - loadChats(); - }} />} /> - } /> - - + + + + { + localStorage.setItem('jc_token', token); + localStorage.setItem('jc_user', JSON.stringify(user)); + setUser(user); + connectWS(token); + loadChats(); + }} />} /> + } /> + + + ); } diff --git a/frontend/src/components/MessageList.tsx b/frontend/src/components/MessageList.tsx index cc77067..0842e06 100644 --- a/frontend/src/components/MessageList.tsx +++ b/frontend/src/components/MessageList.tsx @@ -7,6 +7,7 @@ import { useStore } from '../store'; import api from '../api/client'; import { wsClient } from '../api/ws'; import { ChevronDown } from 'lucide-react'; +import MessageInput from './MessageInput'; interface Props { chatId: string; @@ -176,5 +177,3 @@ export default function MessageList({ chatId, isGroup, canSend }: Props) { ); } -// MessageInput is imported inside -import MessageInput from './MessageInput';