Add username search and improve chat creation UX
All checks were successful
CI / test (push) Successful in 23s

Backend user search:

- Added users search endpoint for @username lookup.

- Implemented repository/service/router support with bounded result limits.

Web chat creation:

- Added API client for /users/search.

- Added NewChatPanel for creating private chats via @username search.

- Added group/channel creation flow from sidebar.

UX refinement:

- Hide message composer when no chat is selected.

- Show explicit placeholder: 'Выберите чат, чтобы начать переписку'.

- Added tsbuildinfo ignore rule.
This commit is contained in:
2026-03-07 22:34:53 +03:00
parent ab65a8b768
commit 9ef9366aca
11 changed files with 225 additions and 8 deletions

View File

@@ -4,8 +4,8 @@ from sqlalchemy.ext.asyncio import AsyncSession
from app.auth.service import get_current_user
from app.database.session import get_db
from app.users.models import User
from app.users.schemas import UserProfileUpdate, UserRead
from app.users.service import get_user_by_id, get_user_by_username, update_user_profile
from app.users.schemas import UserProfileUpdate, UserRead, UserSearchRead
from app.users.service import get_user_by_id, get_user_by_username, search_users_by_username, update_user_profile
router = APIRouter(prefix="/users", tags=["users"])
@@ -15,6 +15,24 @@ async def read_me(current_user: User = Depends(get_current_user)) -> UserRead:
return current_user
@router.get("/search", response_model=list[UserSearchRead])
async def search_users(
query: str,
limit: int = 20,
db: AsyncSession = Depends(get_db),
current_user: User = Depends(get_current_user),
) -> list[UserSearchRead]:
if len(query.strip().lstrip("@")) < 2:
return []
users = await search_users_by_username(
db,
query=query,
limit=limit,
exclude_user_id=current_user.id,
)
return users
@router.get("/{user_id}", response_model=UserRead)
async def read_user(user_id: int, db: AsyncSession = Depends(get_db), _current_user: User = Depends(get_current_user)) -> UserRead:
user = await get_user_by_id(db, user_id)