diff --git a/.changeset/rich-toes-bow.md b/.changeset/rich-toes-bow.md new file mode 100644 index 000000000000..a670f0756f1e --- /dev/null +++ b/.changeset/rich-toes-bow.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Prevented uiInteraction to subscribe multiple times diff --git a/apps/meteor/client/hooks/useAppUiKitInteraction.ts b/apps/meteor/client/hooks/useAppUiKitInteraction.ts index 55741b1961b4..56d984c709e6 100644 --- a/apps/meteor/client/hooks/useAppUiKitInteraction.ts +++ b/apps/meteor/client/hooks/useAppUiKitInteraction.ts @@ -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'; @@ -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]); };