diff --git a/docs/core-checklist-status.md b/docs/core-checklist-status.md index 5c4727f..68fdaa0 100644 --- a/docs/core-checklist-status.md +++ b/docs/core-checklist-status.md @@ -10,7 +10,7 @@ Legend: 1. Account - `PARTIAL` (email auth, JWT, refresh, logout, reset; sessions exist, full UX still improving) 2. User Profile - `DONE` (username, name, avatar, bio, update) 3. User Status - `PARTIAL` (online/last seen/offline; web now formats `just now/today/yesterday/recently`, backend-side presence heuristics still limited) -4. Contacts - `PARTIAL` (list/search/add/remove/block/unblock; `add by email` flow covered by integration tests including `success/not found/blocked conflict`; UX moved to menu) +4. Contacts - `PARTIAL` (list/search/add/remove/block/unblock; `add by email` flow covered by integration tests including `success/not found/blocked conflict`; web now surfaces specific add-by-email errors (`not found` vs `blocked`); UX moved to menu) 5. Chat List - `DONE` (all/pinned/archive/sort/unread; saved-messages delete behavior covered: clear history without deleting chat) 6. Chat Types - `DONE` (private/group/channel) 7. Chat Creation - `DONE` (private/group/channel) diff --git a/web/src/components/ChatList.tsx b/web/src/components/ChatList.tsx index 2500e86..87a8c71 100644 --- a/web/src/components/ChatList.tsx +++ b/web/src/components/ChatList.tsx @@ -1,5 +1,6 @@ import { useEffect, useRef, useState } from "react"; import { createPortal } from "react-dom"; +import axios from "axios"; import { archiveChat, clearChat, createPrivateChat, deleteChat, getChats, getSavedMessagesChat, joinChat, leaveChat, pinChat, unarchiveChat, unpinChat } from "../api/chats"; import { globalSearch } from "../api/search"; import type { DiscoverChat, Message, UserSearchItem } from "../chat/types"; @@ -526,8 +527,20 @@ export function ChatList() { await addContactByEmail(email); setContactEmail(""); setContacts(await listContacts()); - } catch { - setContactEmailError("User with this email not found"); + setContactEmailError(null); + } catch (error) { + if (axios.isAxiosError(error)) { + const status = error.response?.status; + if (status === 404) { + setContactEmailError("User with this email not found"); + return; + } + if (status === 409) { + setContactEmailError("Cannot add contact while blocked"); + return; + } + } + setContactEmailError("Failed to add contact"); } }} type="button"