Skip to content

Commit b802abf

Browse files
[AND-545] Re-order state update sequence to prevent ending up in the wrong state (#1416)
* Re-order state update sequence to prevent ending up in the wrong state * Do not finish the activity twice. * Do not finish the activity twice. * Spotless & apiDump * Revert back default value * Close screen on call ended for `demo-app` to false * Remove finish override * Remove finish override
1 parent bdcda1c commit b802abf

File tree

2 files changed

+8
-10
lines changed
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core
  • stream-video-android-ui-core/src/main/kotlin/io/getstream/video/android/ui/common

2 files changed

+8
-10
lines changed

stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/CallState.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,13 +709,13 @@ public class CallState(
709709
}
710710

711711
is CallCreatedEvent -> {
712-
updateFromResponse(event.call)
713712
getOrCreateMembers(event.members)
713+
updateFromResponse(event.call)
714714
}
715715

716716
is CallRingEvent -> {
717-
updateFromResponse(event.call)
718717
getOrCreateMembers(event.members)
718+
updateFromResponse(event.call)
719719
}
720720

721721
is CallUpdatedEvent -> {
@@ -1330,9 +1330,9 @@ public class CallState(
13301330
}
13311331

13321332
fun updateFromResponse(response: JoinCallResponse) {
1333-
updateFromResponse(response.call)
13341333
_ownCapabilities.value = response.ownCapabilities
13351334
updateFromResponse(response.members)
1335+
updateFromResponse(response.call)
13361336
}
13371337

13381338
fun getMember(userId: String): MemberState? {

stream-video-android-ui-core/src/main/kotlin/io/getstream/video/android/ui/common/StreamCallActivity.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ public abstract class StreamCallActivity : ComponentActivity() {
135135
finish()
136136
}
137137
}
138+
138139
protected val onErrorFinish: suspend (Exception) -> Unit = { error ->
139140
logger.e(error) { "Something went wrong" }
140141
onFailed(error)
@@ -727,13 +728,10 @@ public abstract class StreamCallActivity : ComponentActivity() {
727728
}
728729

729730
is ParticipantLeftEvent, is CallSessionParticipantLeftEvent -> {
730-
val connectionState = call.state.connection.value
731-
if (connectionState == RealtimeConnection.Disconnected) {
732-
val total = call.state.participantCounts.value?.total
733-
logger.d { "Participant left, remaining: $total" }
734-
if (total != null && total <= 2) {
735-
onLastParticipant(call)
736-
}
731+
val total = call.state.participantCounts.value?.total
732+
logger.d { "Participant left, remaining: $total" }
733+
if (total != null && total <= 2) {
734+
onLastParticipant(call)
737735
}
738736
}
739737
}

0 commit comments

Comments
 (0)