- 添加 expiresAt 和 refreshUserSig 参数支持自动续签 - 修改 PushSDK 初始化方式,自动完成设备注册和厂商初始化 - 调整过期续签策略,从提前 15 分钟改为提前 5 分钟触发 - 重构 RN SDK 文档结构,简化安装和使用方式 - 更新统一登录流程,支持 profile 信息传递 - 添加 IM 数据库自动隔离功能 - 修复 Android 群消息聚合问题 - 补充自动化测试验证和错误处理机制
29 行
1.0 KiB
TypeScript
29 行
1.0 KiB
TypeScript
import type { ConversationData, ImMessage } from './types'
|
|
|
|
export function buildDbName(appKey: string, userId: string): string {
|
|
return `xuqm_im_${appKey}_${userId}`
|
|
}
|
|
|
|
export function sortMessages(messages: ImMessage[]): ImMessage[] {
|
|
const deduped = new Map<string, ImMessage>()
|
|
messages.forEach((message) => {
|
|
const existing = deduped.get(message.id)
|
|
if (!existing || message.createdAt >= existing.createdAt) {
|
|
deduped.set(message.id, message)
|
|
}
|
|
})
|
|
return [...deduped.values()]
|
|
.sort((a, b) => {
|
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt
|
|
return b.id.localeCompare(a.id)
|
|
})
|
|
}
|
|
|
|
export function sortConversations(conversations: ConversationData[]): ConversationData[] {
|
|
return [...conversations].sort((a, b) => {
|
|
if (a.isPinned !== b.isPinned) return Number(b.isPinned) - Number(a.isPinned)
|
|
if (b.lastMsgTime !== a.lastMsgTime) return b.lastMsgTime - a.lastMsgTime
|
|
return `${a.chatType}:${a.targetId}`.localeCompare(`${b.chatType}:${b.targetId}`)
|
|
})
|
|
}
|