Skip to content

Commit

Permalink
fix: Inactive Clients Not Refreshing Action Buttons After App Deploym…
Browse files Browse the repository at this point in the history
…ent (#34849)

Co-authored-by: gabriellsh <[email protected]>
  • Loading branch information
Gustrb and gabriellsh authored Jan 13, 2025
1 parent 0517a05 commit 88be133
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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

0 comments on commit 88be133

Please sign in to comment.