diff --git a/src/components/Socket.tsx b/src/components/Socket.tsx index dcfce44..8b76266 100644 --- a/src/components/Socket.tsx +++ b/src/components/Socket.tsx @@ -127,6 +127,10 @@ export const Socket: FC = ({ extensions[conv.counterpartNum].username }` || '', }) + // Update the current call informations for physical devices + dispatch.currentCall.checkAcceptedUpdate({ + acceptedSocket: true, + }) // Add call to transfer calls dispatch.currentCall.addTransferCalls({ type: 'transferred', @@ -411,8 +415,8 @@ export const Socket: FC = ({ dispatchParkingUpdate() }) - // `callNethLink` is the socket event when user make a call or a action from NethLink and has a physical device - socket.current.on('callNethLink', (link, urlType) => { + // `actionNethLink` is the socket event when user make a call or a action from NethLink and has a physical device + socket.current.on('actionNethLink', (link, urlType) => { // Dispatch phone island physical call event with the link and the urlType dispatchUrlCall(link, urlType) }) diff --git a/src/lib/phone/call.ts b/src/lib/phone/call.ts index d91adf5..c88d966 100644 --- a/src/lib/phone/call.ts +++ b/src/lib/phone/call.ts @@ -18,7 +18,6 @@ import { hangupPhysical, answerPhysical, mutePhysical, - unmutePhysical, pausePhysical, callPhysical, toggleRecord, @@ -118,7 +117,7 @@ export function muteCurrentCall() { }) } } else { - mutePhysical() + mutePhysical(true) } eventDispatch('phone-island-call-muted', {}) } @@ -136,7 +135,7 @@ export function unmuteCurrentCall() { }) } } else { - unmutePhysical() + mutePhysical(false) } eventDispatch('phone-island-call-unmuted', {}) } diff --git a/src/models/island.ts b/src/models/island.ts index 15a62bd..815b59c 100644 --- a/src/models/island.ts +++ b/src/models/island.ts @@ -57,7 +57,13 @@ export const island = createModel()({ }), }) -type IslandViewType = 'call' | 'keypad' | 'player' | 'transfer' | 'recorder' | 'physicalPhoneRecorder' +type IslandViewType = + | 'call' + | 'keypad' + | 'player' + | 'transfer' + | 'recorder' + | 'physicalPhoneRecorder' interface IslandTypes { view?: IslandViewType | null diff --git a/src/services/astproxy.ts b/src/services/astproxy.ts index c2409ad..7f6d99e 100644 --- a/src/services/astproxy.ts +++ b/src/services/astproxy.ts @@ -107,11 +107,11 @@ export async function parkConversation(body: { export async function answerPhysical() { // get data - const { ownerExtension } = store.getState().currentCall + const { default_device } = store.getState().currentUser // compose body let body: any = { - endpointId: ownerExtension, + endpointId: default_device?.id, endpointType: 'extension', } @@ -183,36 +183,7 @@ export async function hangupPhysicalRecordingCall() { } } -export async function mutePhysical() { - // get data - const { ownerExtension, conversationId } = store.getState().currentCall - - // compose body - let body: any = { - convid: conversationId, - endpointId: ownerExtension, - } - - try { - const { baseURL, headers } = store.getState().fetchDefaults - const response = await fetch(`${baseURL}/astproxy/mute`, { - method: 'POST', - headers: { ...headers }, - body: JSON.stringify(body), - }) - if (!response.ok) { - throw new Error(response.statusText) - } - store.dispatch.currentCall.updateCurrentCall({ - muted: true, - }) - return true - } catch (error: any) { - throw new Error(error) - } -} - -export async function unmutePhysical() { +export async function mutePhysical(toggleMute: boolean) { // get data const { ownerExtension, conversationId } = store.getState().currentCall @@ -224,7 +195,7 @@ export async function unmutePhysical() { try { const { baseURL, headers } = store.getState().fetchDefaults - const response = await fetch(`${baseURL}/astproxy/unmute`, { + const response = await fetch(`${baseURL}/astproxy/toggle_mute`, { method: 'POST', headers: { ...headers }, body: JSON.stringify(body), @@ -233,7 +204,7 @@ export async function unmutePhysical() { throw new Error(response.statusText) } store.dispatch.currentCall.updateCurrentCall({ - muted: false, + muted: toggleMute, }) return true } catch (error: any) {