Skip to content

Commit 6f8ee14

Browse files
Lipratystd-microblock
authored andcommitted
fix(event): prevent duplicate message triggers of old event
1 parent e1cea77 commit 6f8ee14

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/engine-chronocat-event/src/handler.ts

+6
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ export const buildHandler = (ctx: ChronocatContext) => (data: IpcManData) => {
7272
}
7373
}
7474

75+
const triggeredMsgId = new Set<string>()
76+
7577
const dispatcher = async (
7678
ctx: ChronocatContext,
7779
channel: string,
@@ -86,6 +88,10 @@ const dispatcher = async (
8688
const { msgList } = payload as OnRecvMsg
8789

8890
for (const msg of msgList) {
91+
// prevent duplicate message triggrs
92+
if(triggeredMsgId.has(msg.msgId)) continue
93+
triggeredMsgId.add(msg.msgId)
94+
8995
ctx.chronocat.uix.add(msg.senderUid, msg.senderUin)
9096
if (msg.chatType === ChatType.Private)
9197
ctx.chronocat.uix.add(msg.peerUid, msg.peerUin)

0 commit comments

Comments
 (0)