feat: add saved messages, public chat discovery/join, and chat delete options
All checks were successful
CI / test (push) Successful in 19s

- add Saved Messages system chat with dedicated API

- add public group/channel metadata and discover/join endpoints

- add chat delete flow with for_all option and channel-wide delete

- switch message actions to context menu and improve reply/forward visuals

- improve microphone permission handling for voice recording
This commit is contained in:
2026-03-08 00:41:35 +03:00
parent b5a7d733c6
commit b9f71b9528
12 changed files with 529 additions and 119 deletions

View File

@@ -1,5 +1,5 @@
import { http } from "./http";
import type { Chat, ChatType, Message, MessageType } from "../chat/types";
import type { Chat, ChatType, DiscoverChat, Message, MessageType } from "../chat/types";
import axios from "axios";
export async function getChats(query?: string): Promise<Chat[]> {
@@ -17,11 +17,24 @@ export async function createChat(type: ChatType, title: string | null, memberIds
const { data } = await http.post<Chat>("/chats", {
type,
title,
is_public: false,
member_ids: memberIds
});
return data;
}
export async function createPublicChat(type: "group" | "channel", title: string, handle: string, description?: string): Promise<Chat> {
const { data } = await http.post<Chat>("/chats", {
type,
title,
handle,
description,
is_public: true,
member_ids: []
});
return data;
}
export async function getMessages(chatId: number, beforeId?: number): Promise<Message[]> {
const { data } = await http.get<Message[]>(`/messages/${chatId}`, {
params: {
@@ -132,3 +145,24 @@ export async function pinMessage(chatId: number, messageId: number | null): Prom
});
return data;
}
export async function deleteChat(chatId: number, forAll: boolean): Promise<void> {
await http.delete(`/chats/${chatId}`, { params: { for_all: forAll } });
}
export async function discoverChats(query?: string): Promise<DiscoverChat[]> {
const { data } = await http.get<DiscoverChat[]>("/chats/discover", {
params: query?.trim() ? { query: query.trim() } : undefined
});
return data;
}
export async function joinChat(chatId: number): Promise<Chat> {
const { data } = await http.post<Chat>(`/chats/${chatId}/join`);
return data;
}
export async function getSavedMessagesChat(): Promise<Chat> {
const { data } = await http.get<Chat>("/chats/saved");
return data;
}