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

@@ -7,7 +7,7 @@ interface ChatState {
activeChatId: number | null;
messagesByChat: Record<number, Message[]>;
typingByChat: Record<number, number[]>;
loadChats: () => Promise<void>;
loadChats: (query?: string) => Promise<void>;
setActiveChatId: (chatId: number | null) => void;
loadMessages: (chatId: number) => Promise<void>;
prependMessage: (chatId: number, message: Message) => void;
@@ -29,9 +29,11 @@ export const useChatStore = create<ChatState>((set, get) => ({
activeChatId: null,
messagesByChat: {},
typingByChat: {},
loadChats: async () => {
const chats = await getChats();
set({ chats, activeChatId: chats[0]?.id ?? null });
loadChats: async (query) => {
const chats = await getChats(query);
const currentActive = get().activeChatId;
const nextActive = chats.some((chat) => chat.id === currentActive) ? currentActive : (chats[0]?.id ?? null);
set({ chats, activeChatId: nextActive });
},
setActiveChatId: (chatId) => set({ activeChatId: chatId }),
loadMessages: async (chatId) => {