Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Inactive Clients Not Refreshing Action Buttons After App Deployment #34849

Merged
5 changes: 5 additions & 0 deletions .changeset/eleven-pugs-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes an issue where losing connection could break app's action buttons
7 changes: 4 additions & 3 deletions apps/meteor/client/hooks/useAppActionButtons.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
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';

export const getIdForActionButton = ({ appId, actionId }: IUIActionButton): string => `${appId}/${actionId}`;

export const useAppActionButtons = <TContext extends `${UIActionButtonContext}`>(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 && {
Expand Down
Loading