feat(Dependencies): add new libraries for enhanced functionality and update existing ones
- Added `katex`, `markdown-it`, and `prismjs` for improved rendering of mathematical expressions and markdown content. - Included `react-native-webview` to support web content within the app. - Updated package versions in `package-lock.json` and `package.json` for better compatibility and performance. - Refactored notification handling in `sseService` and `systemNotificationService` to improve user experience with vibration feedback. - Introduced buffering for SSE messages in `messageManager` to prevent race conditions during initialization.
This commit is contained in:
@@ -4,8 +4,6 @@ import EventSource from 'react-native-sse';
|
||||
import { api, SSE_URL } from './api';
|
||||
import { MessageCategory, SystemMessageType, SystemMessageExtraData, MessageSegment } from '../types/dto';
|
||||
import { systemNotificationService } from './systemNotificationService';
|
||||
import { getNotificationPreferencesSync } from './notificationPreferences';
|
||||
import { vibrateOnMessage } from './messageVibrationService';
|
||||
|
||||
export type WSMessageType =
|
||||
| 'chat'
|
||||
@@ -280,7 +278,6 @@ class SSEService {
|
||||
created_at: m.created_at || new Date().toISOString(),
|
||||
};
|
||||
this.emit('group_message', gm);
|
||||
vibrateOnMessage('group_message').catch(() => {});
|
||||
} else {
|
||||
const cm: WSChatMessage = {
|
||||
type: 'chat',
|
||||
@@ -292,7 +289,6 @@ class SSEService {
|
||||
created_at: m.created_at || new Date().toISOString(),
|
||||
};
|
||||
this.emit('chat', cm);
|
||||
vibrateOnMessage('chat').catch(() => {});
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -385,9 +381,6 @@ class SSEService {
|
||||
created_at: payload.created_at || new Date().toISOString(),
|
||||
};
|
||||
this.emit('notification', m);
|
||||
if (getNotificationPreferencesSync().pushEnabled) {
|
||||
vibrateOnMessage('notification').catch(() => {});
|
||||
}
|
||||
systemNotificationService.handleWSMessage(m as any).catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Platform, AppState, AppStateStatus } from 'react-native';
|
||||
import type { WSChatMessage, WSNotificationMessage, WSAnnouncementMessage } from './sseService';
|
||||
import { extractTextFromSegments } from '../types/dto';
|
||||
import { getNotificationPreferencesSync } from './notificationPreferences';
|
||||
import { vibrateOnMessage } from './messageVibrationService';
|
||||
|
||||
// 通知渠道配置
|
||||
const CHANNEL_ID = 'default';
|
||||
@@ -185,6 +186,8 @@ class SystemNotificationService {
|
||||
} else {
|
||||
const notifMsg = message as WSNotificationMessage | WSAnnouncementMessage;
|
||||
void notifMsg;
|
||||
// 系统通知只在后台显示,因此震动也在该分支触发
|
||||
vibrateOnMessage('notification').catch(() => {});
|
||||
await this.showWSNotification(notifMsg);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user