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 inactive client would not be able to see app's action buttons that were added while they were disconnected.
19 changes: 19 additions & 0 deletions apps/meteor/client/hooks/useAppActionButtons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { type IUIActionButton, type UIActionButtonContext } from '@rocket.chat/a
import { useDebouncedCallback } from '@rocket.chat/fuselage-hooks';
import { useEndpoint, useStream, useUserId } from '@rocket.chat/ui-contexts';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { Tracker } from 'meteor/tracker';
import { useEffect } from 'react';

export const getIdForActionButton = ({ appId, actionId }: IUIActionButton): string => `${appId}/${actionId}`;
Expand Down Expand Up @@ -42,6 +43,24 @@ export const useAppActionButtons = <TContext extends `${UIActionButtonContext}`>
[],
);

useEffect(() => {
Gustrb marked this conversation as resolved.
Show resolved Hide resolved
if (!uid) {
return;
}

// Setup Tracker to listen to Meteor's status changes, so we can invalidate the query when the connection is lost
const statusTracker = Tracker.autorun(() => {
const isOffline = !Meteor.status().connected;
Gustrb marked this conversation as resolved.
Show resolved Hide resolved
if (isOffline) {
invalidate();
}
});

return () => {
statusTracker.stop();
};
}, [uid, invalidate]);

useEffect(() => {
if (!uid) {
return;
Expand Down
Loading