From 015eef890949cc13c97cedc64fec1b36834ce65e Mon Sep 17 00:00:00 2001 From: Andriy Shevtsov Date: Mon, 16 Dec 2024 13:38:42 +0200 Subject: [PATCH] fixup! Implement Entry Widget for ongoing engagement cases --- .../engagement/domain/OperatorMediaUseCase.kt | 14 ++++++++++---- .../engagement/domain/VisitorMediaUseCase.kt | 14 ++++++++++---- .../widgets/entrywidget/EntryWidgetController.kt | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/widgetssdk/src/main/java/com/glia/widgets/engagement/domain/OperatorMediaUseCase.kt b/widgetssdk/src/main/java/com/glia/widgets/engagement/domain/OperatorMediaUseCase.kt index 7942b3c6f..7fa1cfb11 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/engagement/domain/OperatorMediaUseCase.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/engagement/domain/OperatorMediaUseCase.kt @@ -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 @@ -16,10 +18,14 @@ internal interface OperatorMediaUseCase { } internal class OperatorMediaUseCaseImpl(private val engagementRepository: EngagementRepository) : OperatorMediaUseCase { - private val operatorMediaState: Flowable = engagementRepository.operatorMediaState - .filter(Data::hasValue) - .map { it as Data.Value } - .map(Data.Value::result) + private val emptyMediaState: MediaState = object : MediaState { + override fun getVideo(): Video? = null + override fun getAudio(): Audio? = null + } + + private val operatorMediaState: Flowable = 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 diff --git a/widgetssdk/src/main/java/com/glia/widgets/engagement/domain/VisitorMediaUseCase.kt b/widgetssdk/src/main/java/com/glia/widgets/engagement/domain/VisitorMediaUseCase.kt index d8078ee77..d809b2d53 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/engagement/domain/VisitorMediaUseCase.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/engagement/domain/VisitorMediaUseCase.kt @@ -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 @@ -17,10 +19,14 @@ internal interface VisitorMediaUseCase { } internal class VisitorMediaUseCaseImpl(private val engagementRepository: EngagementRepository) : VisitorMediaUseCase { - private val visitorMediaState: Flowable = engagementRepository.visitorMediaState - .filter(Data::hasValue) - .map { it as Data.Value } - .map(Data.Value::result) + private val emptyMediaState: MediaState = object : MediaState { + override fun getVideo(): Video? = null + override fun getAudio(): Audio? = null + } + + private val visitorMediaState: Flowable = engagementRepository + .visitorMediaState + .map { if (it is Data.Value) it.result else emptyMediaState } override val onHoldState: Flowable = engagementRepository.onHoldState override val hasAudio: Boolean get() = engagementRepository.visitorCurrentMediaState?.hasAudio ?: false diff --git a/widgetssdk/src/main/java/com/glia/widgets/entrywidget/EntryWidgetController.kt b/widgetssdk/src/main/java/com/glia/widgets/entrywidget/EntryWidgetController.kt index 31431d267..88743d0f4 100644 --- a/widgetssdk/src/main/java/com/glia/widgets/entrywidget/EntryWidgetController.kt +++ b/widgetssdk/src/main/java/com/glia/widgets/entrywidget/EntryWidgetController.kt @@ -63,7 +63,7 @@ internal class EntryWidgetController @JvmOverloads constructor( private val entryWidgetObservableItemType: Flowable> get() = Flowable.combineLatest( engagementStateObservable, - mediaTypeObservable.startWithItem(MediaType.UNKNOWN), + mediaTypeObservable, queueStateObservable, unreadMessagesCountObservable, hasOngoingSCObservable,