From f03e778343afa26ef174eacc13410a85c7b7c020 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Wed, 27 Sep 2023 14:38:29 -0400 Subject: [PATCH] Emit "intent.new" after caching the new Intent Otherwise, if a listener of that event were to trigger a lookup of the same Intent, the lookup wouldn't see the event in the Intent cache, and thus cause a new Intent to be created & new event to be emitted. --- src/appservice/Appservice.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/appservice/Appservice.ts b/src/appservice/Appservice.ts index 27ee5bbb..dc2a8ec2 100644 --- a/src/appservice/Appservice.ts +++ b/src/appservice/Appservice.ts @@ -451,8 +451,8 @@ export class Appservice extends EventEmitter { let intent: Intent = this.intentsCache.get(userId); if (!intent) { intent = new Intent(this.options, userId, this); - this.emit("intent.new", intent); this.intentsCache.set(userId, intent); + this.emit("intent.new", intent); if (this.options.intentOptions.encryption) { intent.enableEncryption().catch(e => { LogService.error("Appservice", `Failed to set up crypto on intent ${userId}`, e);