Skip to content
Snippets Groups Projects
Unverified Commit 55ae5e0e authored by Aleksander Nicacio da Silva's avatar Aleksander Nicacio da Silva Committed by GitHub
Browse files

Regression: Call toggle missing network disconnection state (#26237)

parent 7edd207c
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@ type CallContextReady = {
actions: CallActionsType;
queueName: string;
queueCounter: number;
networkStatus: 'online' | 'offline';
openedRoomInfo: { v: { token?: string }; rid: string };
openWrapUpModal: () => void;
openRoom: (rid: IVoipRoom['_id']) => void;
......@@ -272,3 +273,13 @@ export const useVoipOutboundStates = (): {
outBoundCallsEnabledForUser: isEnterprise && !['IN_CALL', 'ON_HOLD', 'UNREGISTERED', 'INITIAL'].includes(callerInfo.state),
};
};
export const useVoipNetworkStatus = (): 'online' | 'offline' => {
const context = useContext(CallContext);
if (!isCallContextReady(context)) {
throw new Error('useVoipNetworkStatus only if Calls are enabled and ready');
}
return context.networkStatus;
};
......@@ -503,6 +503,7 @@ export const CallProvider: FC = ({ children }) => {
openRoom,
createRoom,
closeRoom,
networkStatus,
openWrapUpModal,
changeAudioOutputDevice,
changeAudioInputDevice,
......@@ -524,6 +525,7 @@ export const CallProvider: FC = ({ children }) => {
openWrapUpModal,
changeAudioOutputDevice,
changeAudioInputDevice,
networkStatus,
]);
return (
......
......@@ -2,7 +2,7 @@ import { Sidebar } from '@rocket.chat/fuselage';
import { useTranslation } from '@rocket.chat/ui-contexts';
import React, { ReactElement, useCallback } from 'react';
import { useCallerInfo, useCallRegisterClient, useCallUnregisterClient } from '../../../contexts/CallContext';
import { useCallerInfo, useCallRegisterClient, useCallUnregisterClient, useVoipNetworkStatus } from '../../../contexts/CallContext';
export const OmnichannelCallToggleReady = ({ ...props }): ReactElement => {
const t = useTranslation();
......@@ -11,7 +11,7 @@ export const OmnichannelCallToggleReady = ({ ...props }): ReactElement => {
const unregister = useCallUnregisterClient();
const register = useCallRegisterClient();
const networkStatus = ['ERROR'].includes(caller.state) ? 'offline' : 'online';
const networkStatus = useVoipNetworkStatus();
const registered = !['ERROR', 'INITIAL', 'UNREGISTERED'].includes(caller.state);
const inCall = ['IN_CALL'].includes(caller.state);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment