Skip to content

Commit 9585f59

Browse files
committed
Code cleanup. Avoid usage of !!
1 parent 9546a73 commit 9585f59

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/ActiveCallManager.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,21 @@ class DefaultActiveCallManager(
180180
}
181181

182182
override suspend fun hungUpCall(callType: CallType) = mutex.withLock {
183-
if (activeCall.value?.callType != callType) {
183+
Timber.tag(tag).d("Hung up call: $callType")
184+
val currentActiveCall = activeCall.value ?: run {
185+
Timber.tag(tag).w("No active call, ignoring hang up")
186+
return
187+
}
188+
if (currentActiveCall.callType != callType) {
184189
Timber.tag(tag).w("Call type $callType does not match the active call type, ignoring")
185190
return
186191
}
187-
188-
Timber.tag(tag).d("Hung up call: $callType")
189-
if (activeCall.value?.callState is CallState.Ringing) {
190-
val ringing = activeCall.value!!.callState as CallState.Ringing
192+
if (currentActiveCall.callState is CallState.Ringing) {
191193
// Decline the call
192-
matrixClientProvider.getOrRestore(ringing.notificationData.sessionId).getOrNull()?.let { client ->
193-
client.getRoom(ringing.notificationData.roomId)?.let { room ->
194-
room.declineCall(ringing.notificationData.eventId)
195-
}
196-
}
194+
val notificationData = currentActiveCall.callState.notificationData
195+
matrixClientProvider.getOrRestore(notificationData.sessionId).getOrNull()
196+
?.getRoom(notificationData.roomId)
197+
?.declineCall(notificationData.eventId)
197198
}
198199

199200
cancelIncomingCallNotification()

0 commit comments

Comments
 (0)