feat(chats): add per-user chat archive support

This commit is contained in:
2026-03-08 09:53:28 +03:00
parent 76f008d635
commit fdf973eeab
10 changed files with 248 additions and 16 deletions

View File

@@ -8,9 +8,12 @@ export interface ChatNotificationSettings {
muted: boolean;
}
export async function getChats(query?: string): Promise<Chat[]> {
export async function getChats(query?: string, archived = false): Promise<Chat[]> {
const { data } = await http.get<Chat[]>("/chats", {
params: query?.trim() ? { query: query.trim() } : undefined
params: {
...(query?.trim() ? { query: query.trim() } : {}),
...(archived ? { archived: true } : {})
}
});
return data;
}
@@ -185,6 +188,16 @@ export async function clearChat(chatId: number): Promise<void> {
await http.post(`/chats/${chatId}/clear`);
}
export async function archiveChat(chatId: number): Promise<Chat> {
const { data } = await http.post<Chat>(`/chats/${chatId}/archive`);
return data;
}
export async function unarchiveChat(chatId: number): Promise<Chat> {
const { data } = await http.post<Chat>(`/chats/${chatId}/unarchive`);
return data;
}
export async function deleteMessage(messageId: number, forAll = false): Promise<void> {
await http.delete(`/messages/${messageId}`, { params: { for_all: forAll } });
}