Files
frontend/src/stores/message/index.ts
lan 48f31e6617
Some checks failed
Frontend CI / ota-android (push) Successful in 1m38s
Frontend CI / ota-ios (push) Successful in 1m38s
Frontend CI / build-and-push-web (push) Successful in 4m28s
Frontend CI / build-android-apk (push) Has been cancelled
feat(message): implement incremental sync and atomic unread updates
Refactor the messaging system to improve synchronization efficiency and state consistency.

- Implement incremental message synchronization using sequence numbers (seq) to reduce payload size.
- Add `markAllAsRead` batch API support to optimize read receipt processing.
- Introduce atomic state updates in `useMessageStore` to prevent inconsistent UI rendering during unread count changes.
- Implement notification deduplication in `WSMessageHandler` to prevent duplicate unread increments during reconnection.
- Optimize `MessageSyncService` to prioritize incremental sync over full snapshots when local data exists.
- Refactor `ReadReceiptManager` to use optimistic updates with proper rollback mechanisms.
- Fix minor UI issues in `SettingsScreen` and `PrivacySettingsScreen` related to theme picker z-index and style application.
2026-05-12 18:04:32 +08:00

117 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 消息模块统一导出
*
* 重构说明:
* - 移除了 MessageStateManager 包装层
* - 直接使用 zustand store 进行状态管理
* - 服务层移至 services/ 目录
* - 新增 hooks.ts 封装常用逻辑
* - 移除了 SubscriptionManager改用 Zustand selector 进行响应式订阅
*/
// ==================== 主管理器 ====================
export { messageManager, MessageManager } from './MessageManager';
// ==================== 状态管理 ====================
export {
useMessageStore,
normalizeConversationId,
mergeMessagesById,
loadPersistedLastSystemMessageAt,
} from './store';
export type { MessageState, MessageActions, MessageStore } from './store';
// ==================== 类型导出 ====================
// 从 types.ts 导出所有类型
export type {
ReadStateRecord,
MessageManagerConversationListDeps,
HandleNewMessageOptions,
IMessageDeduplication,
IUserCacheService,
IReadReceiptManager,
IConversationOperations,
IMessageSendService,
IMessageSyncService,
IWSMessageHandler,
} from './types';
// ==================== 常量导出 ====================
export {
READ_STATE_PROTECTION_DELAY,
PROCESSED_MESSAGE_ID_EXPIRY,
PROCESSED_MESSAGE_ID_MAX_SIZE,
MAX_FLUSH_ITERATIONS,
CONVERSATION_REFRESH_THROTTLE,
MIN_RECONNECT_SYNC_INTERVAL,
} from './constants';
// ==================== 服务导出 ====================
export {
// 消息去重服务
MessageDeduplication,
messageDeduplication,
// 用户缓存服务
UserCacheService,
userCacheService,
// 已读回执管理器
ReadReceiptManager,
// 会话操作服务
ConversationOperations,
// 消息发送服务
MessageSendService,
// 消息同步服务
MessageSyncService,
// WebSocket 消息处理器
WSMessageHandler,
} from './services';
// ==================== Hooks 导出(便捷版,使用 messageManager 单例) ====================
export {
// 会话相关
useConversations,
useConversation,
useCreateConversation,
useUpdateConversation,
// 消息相关
useMessages,
useSendMessage,
useMarkAsRead,
// 未读数相关
useUnreadCount,
useTotalUnreadCount,
useSystemUnreadCount,
// 群聊相关
useGroupTyping,
useGroupMuted,
// 通用
useMessageManager,
useMessageListRefresh,
useChat,
useMessageList,
} from './hooks';
// ==================== 数据源导出 ====================
export {
CONVERSATION_LIST_PAGE_SIZE,
type ConversationListPage,
type IConversationListPagedSource,
type RemoteConversationListSourceKind,
NetworkRemoteConversationListPagedSource,
SqliteConversationListPagedSource,
createRemoteConversationListSource,
} from './sources';
// ==================== 默认导出 ====================
export { default } from './MessageManager';