Skip to content

Commit

Permalink
fixup! Implement Entry Widget for ongoing engagement cases
Browse files Browse the repository at this point in the history
  • Loading branch information
andrews-moc committed Dec 16, 2024
1 parent 1f4342f commit 015eef8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.glia.widgets.engagement.domain

import com.glia.androidsdk.comms.Audio
import com.glia.androidsdk.comms.MediaState
import com.glia.androidsdk.comms.Video
import com.glia.widgets.engagement.EngagementRepository
import com.glia.widgets.helper.Data
import com.glia.widgets.helper.hasAudio
Expand All @@ -16,10 +18,14 @@ internal interface OperatorMediaUseCase {
}

internal class OperatorMediaUseCaseImpl(private val engagementRepository: EngagementRepository) : OperatorMediaUseCase {
private val operatorMediaState: Flowable<MediaState> = engagementRepository.operatorMediaState
.filter(Data<MediaState>::hasValue)
.map { it as Data.Value }
.map(Data.Value<MediaState>::result)
private val emptyMediaState: MediaState = object : MediaState {
override fun getVideo(): Video? = null
override fun getAudio(): Audio? = null
}

private val operatorMediaState: Flowable<MediaState> = engagementRepository
.operatorMediaState
.map { if (it is Data.Value) it.result else emptyMediaState }
override val hasAudio: Boolean get() = engagementRepository.operatorCurrentMediaState?.hasAudio ?: false
override val hasVideo: Boolean get() = engagementRepository.operatorCurrentMediaState?.hasVideo ?: false

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.glia.widgets.engagement.domain

import com.glia.androidsdk.comms.Audio
import com.glia.androidsdk.comms.MediaState
import com.glia.androidsdk.comms.Video
import com.glia.widgets.engagement.EngagementRepository
import com.glia.widgets.helper.Data
import com.glia.widgets.helper.hasAudio
Expand All @@ -17,10 +19,14 @@ internal interface VisitorMediaUseCase {
}

internal class VisitorMediaUseCaseImpl(private val engagementRepository: EngagementRepository) : VisitorMediaUseCase {
private val visitorMediaState: Flowable<MediaState> = engagementRepository.visitorMediaState
.filter(Data<MediaState>::hasValue)
.map { it as Data.Value }
.map(Data.Value<MediaState>::result)
private val emptyMediaState: MediaState = object : MediaState {
override fun getVideo(): Video? = null
override fun getAudio(): Audio? = null
}

private val visitorMediaState: Flowable<MediaState> = engagementRepository
.visitorMediaState
.map { if (it is Data.Value) it.result else emptyMediaState }

override val onHoldState: Flowable<Boolean> = engagementRepository.onHoldState
override val hasAudio: Boolean get() = engagementRepository.visitorCurrentMediaState?.hasAudio ?: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ internal class EntryWidgetController @JvmOverloads constructor(
private val entryWidgetObservableItemType: Flowable<List<EntryWidgetContract.ItemType>>
get() = Flowable.combineLatest(
engagementStateObservable,
mediaTypeObservable.startWithItem(MediaType.UNKNOWN),
mediaTypeObservable,
queueStateObservable,
unreadMessagesCountObservable,
hasOngoingSCObservable,
Expand Down

0 comments on commit 015eef8

Please sign in to comment.