From e5b907d1554e93ca8e4a70b1819ebe08c26da8a3 Mon Sep 17 00:00:00 2001 From: Il Harper Date: Sat, 5 Oct 2024 12:33:06 +0800 Subject: [PATCH] fix(api): remove group in `groupMap` after quit --- packages/engine-chronocat-api/src/handler.ts | 6 ++++-- packages/red/src/redIpcEntity.ts | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/engine-chronocat-api/src/handler.ts b/packages/engine-chronocat-api/src/handler.ts index 131766b..2035de4 100644 --- a/packages/engine-chronocat-api/src/handler.ts +++ b/packages/engine-chronocat-api/src/handler.ts @@ -205,7 +205,7 @@ const responseDispatcher = async ( case 'onGroupListUpdate': case 'nodeIKernelGroupListener/onGroupListUpdate': { - const { groupList } = payload as OnGroupListUpdate + const { groupList, updateType } = payload as OnGroupListUpdate for (const group of groupList) { ctx.chronocatEngineChronocatApi.msgBoxActiv.activate({ @@ -214,7 +214,9 @@ const responseDispatcher = async ( guildId: '', }) - groupMap[group.groupCode] = group + if (updateType === 1) groupMap[group.groupCode] = group + else if (updateType === 3) + if (groupMap[group.groupCode]) delete groupMap[group.groupCode] } chronoEventEmitter.emitGroupListUpdate() diff --git a/packages/red/src/redIpcEntity.ts b/packages/red/src/redIpcEntity.ts index 5b1485e..8cc618c 100644 --- a/packages/red/src/redIpcEntity.ts +++ b/packages/red/src/redIpcEntity.ts @@ -104,7 +104,11 @@ export interface OnEmojiDownloadComplete { } export interface OnGroupListUpdate { - updateType: 1 + /** + * 1 为增加,3 为退出。 + */ + updateType: 1 | 3 + groupList: Group[] }