- add chat_notification_settings table and migration - add chat notifications API (get/update muted) - skip message notifications for muted recipients - add mute/unmute control in chat info panel
This commit is contained in:
@@ -2,6 +2,12 @@ import { http } from "./http";
|
||||
import type { Chat, ChatDetail, ChatMember, ChatMemberRole, ChatType, DiscoverChat, Message, MessageType } from "../chat/types";
|
||||
import axios from "axios";
|
||||
|
||||
export interface ChatNotificationSettings {
|
||||
chat_id: number;
|
||||
user_id: number;
|
||||
muted: boolean;
|
||||
}
|
||||
|
||||
export async function getChats(query?: string): Promise<Chat[]> {
|
||||
const { data } = await http.get<Chat[]>("/chats", {
|
||||
params: query?.trim() ? { query: query.trim() } : undefined
|
||||
@@ -207,3 +213,13 @@ export async function removeChatMember(chatId: number, userId: number): Promise<
|
||||
export async function leaveChat(chatId: number): Promise<void> {
|
||||
await http.post(`/chats/${chatId}/leave`);
|
||||
}
|
||||
|
||||
export async function getChatNotificationSettings(chatId: number): Promise<ChatNotificationSettings> {
|
||||
const { data } = await http.get<ChatNotificationSettings>(`/chats/${chatId}/notifications`);
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function updateChatNotificationSettings(chatId: number, muted: boolean): Promise<ChatNotificationSettings> {
|
||||
const { data } = await http.put<ChatNotificationSettings>(`/chats/${chatId}/notifications`, { muted });
|
||||
return data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user