feat: implement uix add

This commit is contained in:
Il Harper 2024-03-05 22:27:50 +08:00
parent 94262588fc
commit af389039cc
No known key found for this signature in database
GPG Key ID: 4B71FCA698E7E8EC
2 changed files with 110 additions and 1 deletions

View File

@ -2,12 +2,18 @@ import type {
OnAddSendMsg, OnAddSendMsg,
OnBuddyListChange, OnBuddyListChange,
OnGroupListUpdate, OnGroupListUpdate,
OnMemberInfoChange,
OnMemberListChange,
OnMsgInfoListUpdate, OnMsgInfoListUpdate,
OnProfileChanged,
OnRecentContactListChangedVer2,
OnRecvMsg,
OnRichMediaDownloadComplete, OnRichMediaDownloadComplete,
RedIpcArgs, RedIpcArgs,
RedIpcDataEvent, RedIpcDataEvent,
RedIpcDataRequest, RedIpcDataRequest,
} from '@chronocat/red' } from '@chronocat/red'
import { ChatType } from '@chronocat/red'
import type { ChronocatContext } from '@chronocat/shell' import type { ChronocatContext } from '@chronocat/shell'
import type { IpcManData } from 'ipcman' import type { IpcManData } from 'ipcman'
import { ipcMan } from 'ipcman' import { ipcMan } from 'ipcman'
@ -30,6 +36,18 @@ export const version = __DEFINE_CHRONO_VERSION__
export const apply = async (ctx: ChronocatContext) => { export const apply = async (ctx: ChronocatContext) => {
const dispatcher = async (method: string, payload: unknown) => { const dispatcher = async (method: string, payload: unknown) => {
switch (method) { switch (method) {
case 'nodeIKernelMsgListener/onRecvMsg': {
const { msgList } = payload as OnRecvMsg
for (const msg of msgList) {
ctx.chronocat.uix.add(msg.senderUid, msg.senderUin)
if (msg.chatType === ChatType.Private)
ctx.chronocat.uix.add(msg.peerUid, msg.peerUin)
}
return
}
case 'nodeIKernelMsgListener/onRichMediaDownloadComplete': { case 'nodeIKernelMsgListener/onRichMediaDownloadComplete': {
const { notifyInfo } = payload as OnRichMediaDownloadComplete const { notifyInfo } = payload as OnRichMediaDownloadComplete
@ -43,6 +61,45 @@ export const apply = async (ctx: ChronocatContext) => {
return return
} }
case 'nodeIKernelProfileListener/onProfileSimpleChanged':
case 'nodeIKernelProfileListener/onProfileDetailInfoChanged':
case 'nodeIKernelGroupListener/onSearchMemberChange':
case 'nodeIKernelGroupService/getNextMemberList': {
// const authData = await ctx.chronocat.getAuthData()
const { profiles, infos } = payload as OnProfileChanged
// if (profiles.get(authData.uid))
// selfProfile.value = profiles.get(authData.uid)
const profile = profiles ?? infos
for (const [uid, { uin }] of profile) ctx.chronocat.uix.add(uid, uin)
return
}
case 'nodeIKernelGroupListener/onMemberInfoChange': {
const { members } = payload as OnMemberInfoChange
for (const [uid, { uin }] of members) {
ctx.chronocat.uix.add(uid, uin)
}
return
}
case 'nodeIKernelGroupListener/onMemberListChange': {
const { info } = payload as OnMemberListChange
const groupCode = info.sceneId.split('_')[0]
if (!groupCode) return
for (const [uid, { uin }] of info.infos) {
ctx.chronocat.uix.add(uid, uin)
}
return
}
case 'onGroupListUpdate': case 'onGroupListUpdate':
case 'nodeIKernelGroupListener/onGroupListUpdate': { case 'nodeIKernelGroupListener/onGroupListUpdate': {
const { groupList } = payload as OnGroupListUpdate const { groupList } = payload as OnGroupListUpdate
@ -60,6 +117,8 @@ export const apply = async (ctx: ChronocatContext) => {
for (const category of data) { for (const category of data) {
for (const buddy of category.buddyList) { for (const buddy of category.buddyList) {
ctx.chronocat.uix.add(buddy.uid, buddy.uin)
// buddy.category = category.categoryName // buddy.category = category.categoryName
friendMap[buddy.uin] = buddy friendMap[buddy.uin] = buddy
} }
@ -68,6 +127,20 @@ export const apply = async (ctx: ChronocatContext) => {
return return
} }
case 'nodeIKernelRecentContactListener/onRecentContactListChangedVer2': {
const { changedRecentContactLists } =
payload as OnRecentContactListChangedVer2
for (const changedRecentContactList of changedRecentContactLists)
for (const contact of changedRecentContactList.changedList) {
ctx.chronocat.uix.add(contact.senderUid, contact.senderUin)
if (contact.chatType === ChatType.Private)
ctx.chronocat.uix.add(contact.peerUid, contact.peerUin)
}
return
}
case 'nodeIKernelMsgListener/onAddSendMsg': { case 'nodeIKernelMsgListener/onAddSendMsg': {
const { msgRecord } = payload as OnAddSendMsg const { msgRecord } = payload as OnAddSendMsg
sendCallbackMap[msgRecord.msgId] = sendQueue.shift()! sendCallbackMap[msgRecord.msgId] = sendQueue.shift()!

View File

@ -1,10 +1,12 @@
import type { import type {
Element, Element,
OnBuddyListChange,
OnBuddyReqChange, OnBuddyReqChange,
OnMemberInfoChange, OnMemberInfoChange,
OnMemberListChange, OnMemberListChange,
OnMsgInfoListUpdate, OnMsgInfoListUpdate,
OnProfileChanged, OnProfileChanged,
OnRecentContactListChangedVer2,
OnRecvMsg, OnRecvMsg,
Peer, Peer,
RedIpcArgs, RedIpcArgs,
@ -12,7 +14,7 @@ import type {
RedIpcDataRequest, RedIpcDataRequest,
RedMessage, RedMessage,
} from '@chronocat/red' } from '@chronocat/red'
import { MsgType, SendType } from '@chronocat/red' import { ChatType, MsgType, SendType } from '@chronocat/red'
import type { ChronocatContext } from '@chronocat/shell' import type { ChronocatContext } from '@chronocat/shell'
import type { IpcManData } from 'ipcman' import type { IpcManData } from 'ipcman'
import { ipcMan } from 'ipcman' import { ipcMan } from 'ipcman'
@ -34,6 +36,12 @@ export const apply = async (ctx: ChronocatContext) => {
case 'nodeIKernelMsgListener/onRecvMsg': { case 'nodeIKernelMsgListener/onRecvMsg': {
const { msgList } = payload as OnRecvMsg const { msgList } = payload as OnRecvMsg
for (const msg of msgList) {
ctx.chronocat.uix.add(msg.senderUid, msg.senderUin)
if (msg.chatType === ChatType.Private)
ctx.chronocat.uix.add(msg.peerUid, msg.peerUin)
}
// const prepareRole = async (msg: Message) => { // const prepareRole = async (msg: Message) => {
// if (msg.chatType === ChatType.Group) { // if (msg.chatType === ChatType.Group) {
// await getMemberInfo({ // await getMemberInfo({
@ -62,6 +70,7 @@ export const apply = async (ctx: ChronocatContext) => {
if (filteredPayload.length) if (filteredPayload.length)
ctx.chronocat.emit(new MessageCreatedDispatchMessage(filteredPayload)) ctx.chronocat.emit(new MessageCreatedDispatchMessage(filteredPayload))
return return
} }
@ -110,6 +119,33 @@ export const apply = async (ctx: ChronocatContext) => {
return return
} }
case 'nodeIKernelRecentContactListener/onRecentContactListChangedVer2': {
const { changedRecentContactLists } =
payload as OnRecentContactListChangedVer2
for (const changedRecentContactList of changedRecentContactLists)
for (const contact of changedRecentContactList.changedList) {
ctx.chronocat.uix.add(contact.senderUid, contact.senderUin)
if (contact.chatType === ChatType.Private)
ctx.chronocat.uix.add(contact.peerUid, contact.peerUin)
}
return
}
case 'onBuddyListChange':
case 'nodeIKernelBuddyListener/onBuddyListChange': {
const { data } = payload as OnBuddyListChange
for (const category of data) {
for (const buddy of category.buddyList) {
ctx.chronocat.uix.add(buddy.uid, buddy.uin)
}
}
return
}
case 'nodeIKernelBuddyListener/onBuddyReqChange': { case 'nodeIKernelBuddyListener/onBuddyReqChange': {
const { buddyReqs } = payload as OnBuddyReqChange const { buddyReqs } = payload as OnBuddyReqChange