Skip to content

Commit

Permalink
fix: prevent uiInteraction to invalidate multiple times (#33216)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Sep 5, 2024
1 parent 532f088 commit e8baaec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/rich-toes-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Prevented uiInteraction to subscribe multiple times
8 changes: 4 additions & 4 deletions apps/meteor/client/hooks/useAppUiKitInteraction.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import { useStream, useUserId } from '@rocket.chat/ui-contexts';
import type * as UiKit from '@rocket.chat/ui-kit';
import { useEffect } from 'react';
Expand All @@ -6,13 +7,12 @@ export const useAppUiKitInteraction = (handleServerInteraction: (interaction: Ui
const notifyUser = useStream('notify-user');
const uid = useUserId();

const handle = useEffectEvent(handleServerInteraction);
useEffect(() => {
if (!uid) {
return;
}

return notifyUser(`${uid}/uiInteraction`, (interaction) => {
handleServerInteraction(interaction);
});
}, [notifyUser, uid, handleServerInteraction]);
return notifyUser(`${uid}/uiInteraction`, handle);
}, [notifyUser, uid, handle]);
};

0 comments on commit e8baaec

Please sign in to comment.