|
@@ -1,9 +1,9 @@
|
|
|
-import { useState, useEffect, useRef, useCallback } from 'react'
|
|
|
|
|
|
|
+import { useState, useEffect, useRef, useCallback, type ReactNode } from 'react'
|
|
|
import { Contact } from '../types'
|
|
import { Contact } from '../types'
|
|
|
import { api } from '../services/api'
|
|
import { api } from '../services/api'
|
|
|
import { logger } from '../utils/logger'
|
|
import { logger } from '../utils/logger'
|
|
|
import { formatMessageTime } from '../utils/timeUtils'
|
|
import { formatMessageTime } from '../utils/timeUtils'
|
|
|
-import { getSessionAvatar } from '../utils/avatarUtils'
|
|
|
|
|
|
|
+import { renderConversationAvatar } from '../utils/conversationAvatar'
|
|
|
|
|
|
|
|
/** silent:不显示全屏「加载联系人」;失败时跳过更新 */
|
|
/** silent:不显示全屏「加载联系人」;失败时跳过更新 */
|
|
|
export type FetchContactsOptions = { silent?: boolean }
|
|
export type FetchContactsOptions = { silent?: boolean }
|
|
@@ -59,16 +59,24 @@ export function useContacts(
|
|
|
rawTime != null && rawTime !== ''
|
|
rawTime != null && rawTime !== ''
|
|
|
? new Date(rawTime).getTime()
|
|
? new Date(rawTime).getTime()
|
|
|
: undefined
|
|
: undefined
|
|
|
- return {
|
|
|
|
|
|
|
+ const row: Contact = {
|
|
|
id: contact.id,
|
|
id: contact.id,
|
|
|
name: contact.name || `用户${contact.id}`,
|
|
name: contact.name || `用户${contact.id}`,
|
|
|
- avatar: getSessionAvatar(contact.id, contact.name, 40),
|
|
|
|
|
|
|
+ avatar: null as unknown as ReactNode,
|
|
|
lastMessage: contact.last_message,
|
|
lastMessage: contact.last_message,
|
|
|
lastMessageTime: rawTime ? formatMessageTime(rawTime) : undefined,
|
|
lastMessageTime: rawTime ? formatMessageTime(rawTime) : undefined,
|
|
|
lastMessageAt: Number.isFinite(t) ? t : undefined,
|
|
lastMessageAt: Number.isFinite(t) ? t : undefined,
|
|
|
unreadCount: contact.unread_count ?? 0,
|
|
unreadCount: contact.unread_count ?? 0,
|
|
|
- remarks: contact.remarks ?? null
|
|
|
|
|
|
|
+ remarks: contact.remarks ?? null,
|
|
|
|
|
+ is_system: contact.is_system,
|
|
|
|
|
+ app_id: contact.app_id ?? null,
|
|
|
|
|
+ app_name: contact.app_name ?? null,
|
|
|
|
|
+ application_app_id: contact.application_app_id ?? null,
|
|
|
|
|
+ icon_url: contact.icon_url ?? null,
|
|
|
|
|
+ icon_object_key: contact.icon_object_key ?? null
|
|
|
}
|
|
}
|
|
|
|
|
+ row.avatar = renderConversationAvatar(row, 40)
|
|
|
|
|
+ return row
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
setContacts(formattedContacts)
|
|
setContacts(formattedContacts)
|