fix: private chat creation and search in NewChatModal

- Fix: onOpen now async, MainLayout fetches fresh chats before opening
  (was using stale closure, chat wasn't found after creation)
- Fix: search null-safety in user list filter (displayName/username could be undefined)
- Fix: search also matches by phone number

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ai
2026-05-22 12:22:32 +03:00
parent 8e5c4cd67d
commit 5d3be2a628
2 changed files with 21 additions and 18 deletions

View File

@@ -246,9 +246,13 @@ export default function MainLayout() {
</div>
{/* Modals */}
{showNew && <NewChatModal onClose={() => setShowNew(false)} onOpen={(id) => {
const chat = chats.find(c => c.id === id);
if (chat) openChat(chat);
{showNew && <NewChatModal onClose={() => setShowNew(false)} onOpen={async (id) => {
try {
const { data: allChats } = await api.get('/api/chats');
setChats(allChats);
const found = allChats.find((c: any) => c.id === id);
if (found) openChat(found);
} catch {}
}} />}
{showAdmin && <AdminPanel onClose={() => setShowAdmin(false)} />}
{showProfile && <ProfileModal onClose={() => setShowProfile(false)} />}