feat: 优化档案搜索与头像

新增退群监控开关
发送限速
This commit is contained in:
Wxw-Gu
2026-09-03 18:12:29 +08:00
parent 3462d49516
commit 719ffa0a24
33 changed files with 1025 additions and 64 deletions
+34
View File
@@ -0,0 +1,34 @@
import { describe, expect, it } from 'vitest'
import type { Contact } from '../../src/shared/types'
import { selectContactAvatarRefreshUsernames } from '../../src/renderer/src/utils/contact-avatar'
const contact = (username: string, avatar?: string): Contact => ({
m_nsUsrName: username,
m_nsNickName: username,
md5: username,
type: username.endsWith('@chatroom') ? 'group' : 'user',
avatar
})
describe('selectContactAvatarRefreshUsernames', () => {
it('refreshes valid contacts even when they already have a cached avatar', () => {
expect(
selectContactAvatarRefreshUsernames([
contact('wxid_with_stale_avatar', 'https://old.example/avatar.jpg'),
contact('wxid_without_avatar'),
contact('room@chatroom', 'https://old.example/group.jpg')
])
).toEqual(['wxid_with_stale_avatar', 'wxid_without_avatar', 'room@chatroom'])
})
it('deduplicates usernames and skips synthetic contacts', () => {
expect(
selectContactAvatarRefreshUsernames([
contact('wxid_same'),
contact('wxid_same'),
contact('Group_fixture'),
contact('Unknown_fixture')
])
).toEqual(['wxid_same'])
})
})