Skip to content

Commit 026c563

Browse files
committed
slice: useCallStore participant model migration
1 parent c150713 commit 026c563

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

app/lib/services/voip/useCallStore.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,20 @@ function createMockCall(callId: string) {
3838
const call = {
3939
callId,
4040
state: 'active',
41-
muted: false,
42-
held: false,
43-
remoteMute: false,
44-
remoteHeld: false,
41+
localParticipant: {
42+
muted: false,
43+
held: false,
44+
contact: { id: 'u', displayName: 'U', username: 'u', sipExtension: '' },
45+
setMuted: jest.fn(),
46+
setHeld: jest.fn()
47+
},
48+
remoteParticipants: [{
49+
muted: false,
50+
held: false
51+
}],
4552
hidden: false,
4653
role: 'callee',
47-
contact: { id: 'u', displayName: 'U', username: 'u', sipExtension: '' },
4854
emitter,
49-
setMuted: jest.fn(),
50-
setHeld: jest.fn(),
5155
sendDTMF: jest.fn(),
5256
hangup: jest.fn(),
5357
accept: jest.fn(),

app/lib/services/voip/useCallStore.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,19 @@ export const useCallStore = create<CallStore>((set, get) => ({
139139
setCall: (call: IClientMediaCall) => {
140140
cleanupCallListeners();
141141
get().resetNativeCallId();
142-
// Update state with call info — muted/held/remoteMute/remoteHeld/contact removed in 0.2.0-rc.0 library, migrated from 0.1.3 API
143142
set({
144143
call,
145144
callId: call.callId,
146145
callState: call.state,
147-
isMuted: (call as any).muted,
148-
isOnHold: (call as any).held,
149-
remoteMute: (call as any).remoteMute,
150-
remoteHeld: (call as any).remoteHeld,
146+
isMuted: call.localParticipant.muted,
147+
isOnHold: call.localParticipant.held,
148+
remoteMute: call.remoteParticipants[0]?.muted ?? false,
149+
remoteHeld: call.remoteParticipants[0]?.held ?? false,
151150
contact: {
152-
id: (call as any).contact.id,
153-
displayName: (call as any).contact.displayName,
154-
username: (call as any).contact.username,
155-
sipExtension: (call as any).contact.sipExtension
151+
id: call.localParticipant.contact.id,
152+
displayName: call.localParticipant.contact.displayName,
153+
username: call.localParticipant.contact.username,
154+
sipExtension: call.localParticipant.contact.sipExtension
156155
},
157156
callStartTime: call.state === 'active' ? Date.now() : null
158157
});
@@ -187,12 +186,11 @@ export const useCallStore = create<CallStore>((set, get) => ({
187186
const currentCall = get().call;
188187
if (!currentCall) return;
189188

190-
// muted/held/remoteMute/remoteHeld removed in 0.2.0-rc.0 library, migrated from 0.1.3 API
191189
set({
192-
isMuted: (currentCall as any).muted,
193-
isOnHold: (currentCall as any).held,
194-
remoteMute: (currentCall as any).remoteMute,
195-
remoteHeld: (currentCall as any).remoteHeld,
190+
isMuted: currentCall.localParticipant.muted,
191+
isOnHold: currentCall.localParticipant.held,
192+
remoteMute: currentCall.remoteParticipants[0]?.muted ?? false,
193+
remoteHeld: currentCall.remoteParticipants[0]?.held ?? false,
196194
controlsVisible: true
197195
});
198196
};
@@ -226,17 +224,15 @@ export const useCallStore = create<CallStore>((set, get) => ({
226224
const { call, isMuted } = get();
227225
if (!call) return;
228226

229-
// setMuted removed in 0.2.0-rc.0 library, migrated from 0.1.3 API
230-
(call as any).setMuted(!isMuted);
227+
call.localParticipant.setMuted(!isMuted);
231228
set({ isMuted: !isMuted });
232229
},
233230

234231
toggleHold: () => {
235232
const { call, isOnHold } = get();
236233
if (!call) return;
237234

238-
// setHeld removed in 0.2.0-rc.0 library, migrated from 0.1.3 API
239-
(call as any).setHeld(!isOnHold);
235+
call.localParticipant.setHeld(!isOnHold);
240236
set({ isOnHold: !isOnHold });
241237
},
242238

0 commit comments

Comments
 (0)