chore(deps): upgrade Expo SDK from 55 to 56
Migrate from @react-navigation/native to expo-router navigation hooks across all screens. Add polyfills module and apply LiveKit VideoView optional loading for Expo Go compatibility. Improve background sync to skip when user is not logged in. Enhance fetchUnreadCount to return typed totalUnread and systemUnread values.
This commit is contained in:
@@ -208,7 +208,7 @@ class MessageManager {
|
||||
return this.syncService.loadMoreMessages(conversationId, beforeSeq, limit);
|
||||
}
|
||||
|
||||
async fetchUnreadCount(): Promise<void> {
|
||||
async fetchUnreadCount(): Promise<{ totalUnread: number; systemUnread: number }> {
|
||||
return this.syncService.fetchUnreadCount();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ export class MessageSyncService implements IMessageSyncService {
|
||||
/** 正在加载会话列表下一页 */
|
||||
private loadingMoreConversations = false;
|
||||
/** fetchUnreadCount 去重:复用 in-flight promise */
|
||||
private fetchUnreadCountPromise: Promise<void> | null = null;
|
||||
private fetchUnreadCountPromise: Promise<{ totalUnread: number; systemUnread: number }> | null = null;
|
||||
|
||||
constructor(
|
||||
getCurrentUserId: () => string | null,
|
||||
@@ -352,19 +352,20 @@ export class MessageSyncService implements IMessageSyncService {
|
||||
/**
|
||||
* 获取未读数(去重:复用 in-flight promise)
|
||||
*/
|
||||
async fetchUnreadCount(): Promise<void> {
|
||||
async fetchUnreadCount(): Promise<{ totalUnread: number; systemUnread: number }> {
|
||||
if (this.fetchUnreadCountPromise) {
|
||||
return this.fetchUnreadCountPromise;
|
||||
}
|
||||
this.fetchUnreadCountPromise = this.doFetchUnreadCount();
|
||||
try {
|
||||
await this.fetchUnreadCountPromise;
|
||||
const result = await this.fetchUnreadCountPromise;
|
||||
return result;
|
||||
} finally {
|
||||
this.fetchUnreadCountPromise = null;
|
||||
}
|
||||
}
|
||||
|
||||
private async doFetchUnreadCount(): Promise<void> {
|
||||
private async doFetchUnreadCount(): Promise<{ totalUnread: number; systemUnread: number }> {
|
||||
const store = useMessageStore.getState();
|
||||
|
||||
try {
|
||||
@@ -392,8 +393,10 @@ export class MessageSyncService implements IMessageSyncService {
|
||||
|
||||
// 服务端汇总未读为 0:不主动清零本地未读,等 fetchConversations 提供权威数据
|
||||
// 避免后端缓存竞态导致的未读数抖动
|
||||
return { totalUnread, systemUnread };
|
||||
} catch (error) {
|
||||
console.error('[MessageSyncService] 获取未读数失败:', error);
|
||||
return { totalUnread: 0, systemUnread: 0 };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user