Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(event): prevent duplicate message triggers of old event #13

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading