Skip to content

Commit dcb25cd

Browse files
committed
remove unnecessary checks for doesParticipantExist
add log in getParticipant if not found Signed-off-by: Marcel Hibbe <[email protected]>
1 parent fc33726 commit dcb25cd

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,7 +2120,6 @@ class CallActivity : CallBaseActivity() {
21202120
it.stopCapture()
21212121
it.startCapture(width, height, FRAME_RATE)
21222122
}
2123-
// updateSelfVideoViewPosition(isPortrait)
21242123
}
21252124

21262125
private fun setupOrientationListener(context: Context) {
@@ -2453,13 +2452,12 @@ class CallActivity : CallBaseActivity() {
24532452
peerConnectionWrapper.removeObserver(selfPeerConnectionObserver)
24542453
}
24552454

2456-
if (!callViewModel.doesParticipantExist(sessionId)) {
2457-
if ("screen" == type) {
2458-
callViewModel.getParticipant(sessionId)?.setScreenPeerConnection(null)
2459-
} else {
2460-
callViewModel.getParticipant(sessionId)?.setPeerConnection(null)
2461-
}
2455+
if ("screen" == type) {
2456+
callViewModel.getParticipant(sessionId)?.setScreenPeerConnection(null)
2457+
} else {
2458+
callViewModel.getParticipant(sessionId)?.setPeerConnection(null)
24622459
}
2460+
24632461
peerConnectionWrapper.removePeerConnection()
24642462
peerConnectionWrapperList.remove(peerConnectionWrapper)
24652463
}
@@ -2797,9 +2795,7 @@ class CallActivity : CallBaseActivity() {
27972795

27982796
private fun onOfferOrAnswer(nick: String?) {
27992797
this.nick = nick
2800-
if (callViewModel.doesParticipantExist(sessionId)) {
2801-
callViewModel.getParticipant(sessionId)?.updateNick(nick)
2802-
}
2798+
callViewModel.getParticipant(sessionId)?.updateNick(nick)
28032799
}
28042800
}
28052801

app/src/main/java/com/nextcloud/talk/activities/CallViewModel.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package com.nextcloud.talk.activities
88

9+
import android.util.Log
910
import androidx.lifecycle.ViewModel
1011
import androidx.lifecycle.viewModelScope
1112
import com.nextcloud.talk.signaling.SignalingMessageReceiver
@@ -26,7 +27,13 @@ class CallViewModel @Inject constructor() : ViewModel() {
2627
private val _activeScreenShareSession = MutableStateFlow<ParticipantUiState?>(null)
2728
val activeScreenShareSession: StateFlow<ParticipantUiState?> = _activeScreenShareSession.asStateFlow()
2829

29-
fun getParticipant(sessionId: String?): ParticipantHandler? = participantHandlers[sessionId]
30+
fun getParticipant(sessionId: String?): ParticipantHandler? {
31+
if (sessionId == null) {
32+
Log.w(TAG, "Attempted to get participant with null sessionId.")
33+
return null
34+
}
35+
return participantHandlers[sessionId]
36+
}
3037

3138
fun doesParticipantExist(sessionId: String?): Boolean = (participantHandlers.containsKey(sessionId))
3239

@@ -86,4 +93,8 @@ class CallViewModel @Inject constructor() : ViewModel() {
8693
participantHandlers.clear()
8794
_participants.value = emptyList()
8895
}
96+
97+
companion object {
98+
private val TAG = CallViewModel::class.java.simpleName
99+
}
89100
}

0 commit comments

Comments
 (0)