feat(chats): add per-user chat archive support
This commit is contained in:
@@ -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 } });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user