feat: add search APIs and telegram-like chats sidebar flow
All checks were successful
CI / test (push) Successful in 24s
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:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user