Skip to content

Commit

Permalink
fix: VoIP not invalidating cache on permission change (#34102)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandernsilva authored Dec 5, 2024
1 parent 94aa6af commit b7e1dd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-wolves-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/ui-voip": patch
---

Fixes an issue preventing VoIP permission updates from being properly reflected in the UI.
7 changes: 3 additions & 4 deletions packages/ui-voip/src/hooks/useVoipClient.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useUser, useEndpoint, useSetting } from '@rocket.chat/ui-contexts';
import { useUser, useEndpoint } from '@rocket.chat/ui-contexts';
import { useQuery } from '@tanstack/react-query';
import { useEffect, useRef } from 'react';

import VoipClient from '../lib/VoipClient';
import { useWebRtcServers } from './useWebRtcServers';
import VoipClient from '../lib/VoipClient';

type VoipClientParams = {
enabled?: boolean;
Expand All @@ -17,15 +17,14 @@ type VoipClientResult = {

export const useVoipClient = ({ enabled = true, autoRegister = true }: VoipClientParams = {}): VoipClientResult => {
const { _id: userId } = useUser() || {};
const isVoipEnabled = useSetting('VoIP_TeamCollab_Enabled', false);
const voipClientRef = useRef<VoipClient | null>(null);

const getRegistrationInfo = useEndpoint('GET', '/v1/voip-freeswitch.extension.getRegistrationInfoByUserId');

const iceServers = useWebRtcServers();

const { data: voipClient, error } = useQuery<VoipClient | null, Error>(
['voip-client', isVoipEnabled, userId, iceServers],
['voip-client', enabled, userId, iceServers],
async () => {
if (voipClientRef.current) {
voipClientRef.current.clear();
Expand Down

0 comments on commit b7e1dd3

Please sign in to comment.