Skip to content

Commit

Permalink
Handle null started_at in call state (#879)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNovak authored Oct 19, 2023
1 parent daffaaa commit 307fafb
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ public class CallState(
_participants.mapState { it.values.toList() }

private val _startedAt: MutableStateFlow<OffsetDateTime?> = MutableStateFlow(null)

/**
* Will return always null with current SFU implementation - it may be fixed later. For now
* do not use it.
*/
public val startedAt: StateFlow<OffsetDateTime?> = _startedAt

private val _participantCounts: MutableStateFlow<ParticipantCount?> = MutableStateFlow(null)
Expand Down Expand Up @@ -896,8 +901,14 @@ public class CallState(
// update the participant count
_participantCounts.value = event.participantCount

val instant = Instant.ofEpochSecond(event.callState.started_at?.epochSecond!!, 0)
_startedAt.value = OffsetDateTime.ofInstant(instant, ZoneOffset.UTC)
val startedAt = event.callState.started_at
if (startedAt != null) {
val instant = Instant.ofEpochSecond(startedAt.epochSecond, 0)
_startedAt.value = OffsetDateTime.ofInstant(instant, ZoneOffset.UTC)
} else {
_startedAt.value = null
}

// creates the participants
val participantStates = event.callState.participants.map {
getOrCreateParticipant(it)
Expand Down

0 comments on commit 307fafb

Please sign in to comment.