From 88be13370d07eaf58005d5008435c7dff6baa318 Mon Sep 17 00:00:00 2001 From: Gustavo Reis Bauer Date: Mon, 13 Jan 2025 11:24:03 -0300 Subject: [PATCH] fix: Inactive Clients Not Refreshing Action Buttons After App Deployment (#34849) Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com> --- .changeset/eleven-pugs-help.md | 5 +++++ apps/meteor/client/hooks/useAppActionButtons.ts | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/eleven-pugs-help.md diff --git a/.changeset/eleven-pugs-help.md b/.changeset/eleven-pugs-help.md new file mode 100644 index 000000000000..61acd79f600b --- /dev/null +++ b/.changeset/eleven-pugs-help.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fixes an issue where losing connection could break app's action buttons diff --git a/apps/meteor/client/hooks/useAppActionButtons.ts b/apps/meteor/client/hooks/useAppActionButtons.ts index 566baf69b37c..58173987308a 100644 --- a/apps/meteor/client/hooks/useAppActionButtons.ts +++ b/apps/meteor/client/hooks/useAppActionButtons.ts @@ -1,6 +1,6 @@ import { type IUIActionButton, type UIActionButtonContext } from '@rocket.chat/apps-engine/definition/ui'; import { useDebouncedCallback } from '@rocket.chat/fuselage-hooks'; -import { useEndpoint, useStream, useUserId } from '@rocket.chat/ui-contexts'; +import { useConnectionStatus, useEndpoint, useStream, useUserId } from '@rocket.chat/ui-contexts'; import { useQuery, useQueryClient } from '@tanstack/react-query'; import { useEffect } from 'react'; @@ -8,14 +8,15 @@ export const getIdForActionButton = ({ appId, actionId }: IUIActionButton): stri export const useAppActionButtons = (context?: TContext) => { const queryClient = useQueryClient(); - const apps = useStream('apps'); const uid = useUserId(); + const { status } = useConnectionStatus(); const getActionButtons = useEndpoint('GET', '/apps/actionButtons'); const result = useQuery({ - queryKey: ['apps', 'actionButtons'], + queryKey: ['apps', 'actionButtons', status], + enabled: status === 'connected', queryFn: () => getActionButtons(), ...(context && {