diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/data/WidgetMessage.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/data/WidgetMessage.kt index c18fef410e..5001d598d9 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/data/WidgetMessage.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/data/WidgetMessage.kt @@ -41,5 +41,8 @@ data class WidgetMessage( @SerialName("send_event") SendEvent, + + @SerialName("content_loaded") + ContentLoaded, } } diff --git a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenPresenter.kt b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenPresenter.kt index d82c64b607..c1c58d4607 100644 --- a/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenPresenter.kt +++ b/features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenPresenter.kt @@ -79,7 +79,7 @@ class CallScreenPresenter( val urlState = remember { mutableStateOf>(AsyncData.Uninitialized) } val callWidgetDriver = remember { mutableStateOf(null) } val messageInterceptor = remember { mutableStateOf(null) } - var isJoinedCall by rememberSaveable { mutableStateOf(false) } + var isWidgetLoaded by rememberSaveable { mutableStateOf(false) } var ignoreWebViewError by rememberSaveable { mutableStateOf(false) } var webViewError by remember { mutableStateOf(null) } val languageTag = languageTagProvider.provideLanguageTag() @@ -139,8 +139,8 @@ class CallScreenPresenter( if (parsedMessage?.direction == WidgetMessage.Direction.FromWidget) { if (parsedMessage.action == WidgetMessage.Action.Close) { close(callWidgetDriver.value, navigator) - } else if (parsedMessage.action == WidgetMessage.Action.Join) { - isJoinedCall = true + } else if (parsedMessage.action == WidgetMessage.Action.ContentLoaded) { + isWidgetLoaded = true } } } @@ -151,8 +151,8 @@ class CallScreenPresenter( // Wait for the call to be joined, if it takes too long, we display an error delay(10.seconds) - if (!isJoinedCall) { - Timber.w("The call took too long to be joined. Displaying an error before exiting.") + if (!isWidgetLoaded) { + Timber.w("The call took too long to load. Displaying an error before exiting.") // This will display a simple 'Sorry, an error occurred' dialog and force the user to exit the call webViewError = "" @@ -165,10 +165,10 @@ class CallScreenPresenter( is CallScreenEvents.Hangup -> { val widgetId = callWidgetDriver.value?.id val interceptor = messageInterceptor.value - if (widgetId != null && interceptor != null && isJoinedCall) { + if (widgetId != null && interceptor != null && isWidgetLoaded) { // If the call was joined, we need to hang up first. Then the UI will be dismissed automatically. sendHangupMessage(widgetId, interceptor) - isJoinedCall = false + isWidgetLoaded = false coroutineScope.launch { // Wait for a couple of seconds to receive the hangup message @@ -198,7 +198,7 @@ class CallScreenPresenter( urlState = urlState.value, webViewError = webViewError, userAgent = userAgent, - isCallActive = isJoinedCall, + isCallActive = isWidgetLoaded, isInWidgetMode = isInWidgetMode, eventSink = { handleEvents(it) }, ) diff --git a/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt b/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt index 15f1334773..47a91afa1c 100644 --- a/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt +++ b/features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt @@ -215,7 +215,7 @@ import kotlin.time.Duration.Companion.seconds } @Test - fun `present - a received 'joined' action makes the call to be active`() = runTest { + fun `present - a received 'content loaded' action makes the call to be active`() = runTest { val navigator = FakeCallScreenNavigator() val widgetDriver = FakeMatrixWidgetDriver() val presenter = createCallScreenPresenter( @@ -238,7 +238,7 @@ import kotlin.time.Duration.Companion.seconds messageInterceptor.givenInterceptedMessage( """ { - "action":"io.element.join", + "action":"content_loaded", "api":"fromWidget", "widgetId":"1", "requestId":"1"