Skip to content

Commit

Permalink
Emit "intent.new" after caching the new Intent
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AndrewFerr committed Sep 27, 2023
1 parent ee77957 commit f03e778
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/appservice/Appservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f03e778

Please sign in to comment.