Skip to content

Commit

Permalink
fix(event): prevent duplicate message triggers of old event
Browse files Browse the repository at this point in the history
  • Loading branch information
Lipraty authored Jan 30, 2025
1 parent e1cea77 commit 96c8d66
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/engine-chronocat-event/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export const buildHandler = (ctx: ChronocatContext) => (data: IpcManData) => {
}
}

const triggeredMsgId = new Set<string>()

const dispatcher = async (
ctx: ChronocatContext,
channel: string,
Expand All @@ -86,6 +88,10 @@ const dispatcher = async (
const { msgList } = payload as OnRecvMsg

for (const msg of msgList) {
// prevent duplicate message triggrs
if(triggeredMsgId.has(msg.msgId)) continue
triggeredMsgId.add(msg.msgId)

ctx.chronocat.uix.add(msg.senderUid, msg.senderUin)
if (msg.chatType === ChatType.Private)
ctx.chronocat.uix.add(msg.peerUid, msg.peerUin)
Expand Down

0 comments on commit 96c8d66

Please sign in to comment.