@@ -287,7 +287,11 @@ final class IndividualCallService: CallServiceStateObserver {
287287 opaque: Data ,
288288 identityKeys: CallIdentityKeys ?
289289 ) {
290- guard let currentCall = callServiceState. currentCall, currentCall. individualCall? . callId == callId else {
290+ guard
291+ let currentCall = callServiceState. currentCall,
292+ currentCall. isIndividualCall,
293+ currentCall. individualCall. callId == callId
294+ else {
291295 return
292296 }
293297
@@ -330,7 +334,11 @@ final class IndividualCallService: CallServiceStateObserver {
330334
331335 @MainActor
332336 private func _handleReceivedIceCandidates( callId: UInt64 , sourceDevice: DeviceId , iceCandidates: [ Data ] ) {
333- guard let currentCall = callServiceState. currentCall, currentCall. individualCall? . callId == callId else {
337+ guard
338+ let currentCall = callServiceState. currentCall,
339+ currentCall. isIndividualCall,
340+ currentCall. individualCall. callId == callId
341+ else {
334342 return
335343 }
336344
@@ -365,7 +373,11 @@ final class IndividualCallService: CallServiceStateObserver {
365373
366374 @MainActor
367375 private func _handleReceivedHangup( callId: UInt64 , sourceDevice: DeviceId , hangupType: HangupType , deviceId: UInt32 ) {
368- guard let currentCall = callServiceState. currentCall, currentCall. individualCall? . callId == callId else {
376+ guard
377+ let currentCall = callServiceState. currentCall,
378+ currentCall. isIndividualCall,
379+ currentCall. individualCall. callId == callId
380+ else {
369381 return
370382 }
371383
@@ -390,7 +402,11 @@ final class IndividualCallService: CallServiceStateObserver {
390402
391403 @MainActor
392404 private func _handleReceivedBusy( callId: UInt64 , sourceDevice: DeviceId ) {
393- guard let currentCall = callServiceState. currentCall, currentCall. individualCall? . callId == callId else {
405+ guard
406+ let currentCall = callServiceState. currentCall,
407+ currentCall. isIndividualCall,
408+ currentCall. individualCall. callId == callId
409+ else {
394410 return
395411 }
396412
@@ -1006,7 +1022,7 @@ final class IndividualCallService: CallServiceStateObserver {
10061022 case . contactIsBlocked:
10071023 callType = . incomingMissedBecauseBlockedSystemContact
10081024 default :
1009- if call. individualCall? . direction == . outgoing {
1025+ if call. individualCall. direction == . outgoing {
10101026 callType = . outgoingMissed
10111027 } else {
10121028 callType = . incomingMissed
@@ -1341,7 +1357,20 @@ extension TSRecentCallOfferType {
13411357}
13421358
13431359private extension SignalCall {
1344- var individualCall : IndividualCall ! {
1360+ /// Whether this call is an individual call.
1361+ /// - SeeAlso ``individualCall``
1362+ var isIndividualCall : Bool {
1363+ switch self . mode {
1364+ case . individual: return true
1365+ case . groupThread, . callLink: return false
1366+ }
1367+ }
1368+
1369+ /// - Important
1370+ /// Callers must be *sure* that this `SignalCall` represents an individual
1371+ /// call, either contextually or by consulting ``isIndividualCall``.
1372+ /// - SeeAlso ``isIndividualCall``
1373+ var individualCall : IndividualCall {
13451374 switch self . mode {
13461375 case . individual( let individualCall) :
13471376 return individualCall
0 commit comments