feat: add search APIs and telegram-like chats sidebar flow
All checks were successful
CI / test (push) Successful in 24s

- implement chat query filtering and message search endpoints

- add db indexes for search fields

- activate chats search input in web

- replace inline create panel with floating TG-style action menu
This commit is contained in:
2026-03-08 00:19:34 +03:00
parent 0a602e4078
commit 4d704fc279
11 changed files with 299 additions and 86 deletions

View File

@@ -2,8 +2,10 @@ import { http } from "./http";
import type { Chat, ChatType, Message, MessageType } from "../chat/types";
import axios from "axios";
export async function getChats(): Promise<Chat[]> {
const { data } = await http.get<Chat[]>("/chats");
export async function getChats(query?: string): Promise<Chat[]> {
const { data } = await http.get<Chat[]>("/chats", {
params: query?.trim() ? { query: query.trim() } : undefined
});
return data;
}
@@ -30,6 +32,16 @@ export async function getMessages(chatId: number, beforeId?: number): Promise<Me
return data;
}
export async function searchMessages(query: string, chatId?: number): Promise<Message[]> {
const { data } = await http.get<Message[]>("/messages/search", {
params: {
query,
chat_id: chatId
}
});
return data;
}
export async function sendMessage(chatId: number, text: string, type: MessageType = "text"): Promise<Message> {
const { data } = await http.post<Message>("/messages", { chat_id: chatId, text, type });
return data;