feat(message): add conversation notification mute feature
Add notification mute functionality for conversations with the following changes: - Add notification_muted field to ConversationResponse and related DTOs - Add notificationMutedMap to message store for tracking mute state - Add setConversationNotificationMuted API method - Integrate mute toggle in GroupInfoScreen and PrivateChatInfoScreen - Skip system notifications for muted conversations - Suppress vibration for muted conversations in WS handler - Clean up selected mentions when @mentions are removed from text Chore changes: - Update PostCard bookmark icon from 'bookmark' to 'star' - Refine card styles across AppsScreen, MaterialsScreen, and SubjectMaterialsScreen - Improve week selector scrolling to center selected week in ScheduleScreen
This commit is contained in:
@@ -274,6 +274,12 @@ class MessageService {
|
||||
});
|
||||
}
|
||||
|
||||
async setConversationNotificationMuted(conversationId: string, notificationMuted: boolean): Promise<void> {
|
||||
await api.put(`/conversations/${encodeURIComponent(conversationId)}/notification_muted`, {
|
||||
notification_muted: notificationMuted,
|
||||
});
|
||||
}
|
||||
|
||||
// ==================== 消息相关 ====================
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,6 +10,8 @@ import type { WSChatMessage, WSNotificationMessage, WSAnnouncementMessage } from
|
||||
import { extractTextFromSegments } from '@/types/dto';
|
||||
import { getNotificationPreferencesSync } from './notificationPreferences';
|
||||
import { vibrateOnMessage } from '../platform/messageVibrationService';
|
||||
import { useMessageStore } from '@/stores/message/store';
|
||||
import { normalizeConversationId } from '@/stores/message/store';
|
||||
|
||||
// 通知渠道配置
|
||||
const CHANNEL_ID = 'default';
|
||||
@@ -207,9 +209,12 @@ class SystemNotificationService {
|
||||
// 判断是否是聊天消息(通过 segments 字段)
|
||||
if ('segments' in message) {
|
||||
const chatMsg = message as WSChatMessage;
|
||||
const body = extractTextFromSegments(chatMsg.segments);
|
||||
const conversationId = normalizeConversationId(chatMsg.conversation_id);
|
||||
const isNotificationMuted = useMessageStore.getState().isNotificationMuted(conversationId);
|
||||
if (isNotificationMuted) {
|
||||
return;
|
||||
}
|
||||
void chatMsg;
|
||||
void body;
|
||||
await this.showChatNotification(chatMsg);
|
||||
} else {
|
||||
const notifMsg = message as WSNotificationMessage | WSAnnouncementMessage;
|
||||
|
||||
Reference in New Issue
Block a user