Skip to content

Commit cf57927

Browse files
committed
Show error screens in group calls
Element Call now sends a 'close' widget action when the widget is ready to close. Usually this will be sent immediately after the 'hangup' action, but it could be sent later if the widget wants to present an error screen before closing. So by listening to the 'close' action rather than the 'hangup' action, we get to see these error screens.
1 parent 5d8403b commit cf57927

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

features/call/impl/src/main/kotlin/io/element/android/features/call/impl/data/WidgetMessage.kt

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ data class WidgetMessage(
3333
@SerialName("im.vector.hangup")
3434
HangUp,
3535

36+
@SerialName("io.element.close")
37+
Close,
38+
3639
@SerialName("send_event")
3740
SendEvent,
3841
}

features/call/impl/src/main/kotlin/io/element/android/features/call/impl/ui/CallScreenPresenter.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class CallScreenPresenter @AssistedInject constructor(
135135

136136
val parsedMessage = parseMessage(it)
137137
if (parsedMessage?.direction == WidgetMessage.Direction.FromWidget) {
138-
if (parsedMessage.action == WidgetMessage.Action.HangUp) {
138+
if (parsedMessage.action == WidgetMessage.Action.Close) {
139139
close(callWidgetDriver.value, navigator)
140140
} else if (parsedMessage.action == WidgetMessage.Action.SendEvent) {
141141
// This event is received when a member joins the call, the first one will be the current one

features/call/impl/src/test/kotlin/io/element/android/features/call/ui/CallScreenPresenterTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class CallScreenPresenterTest {
174174

175175
@OptIn(ExperimentalCoroutinesApi::class)
176176
@Test
177-
fun `present - a received hang up message closes the screen and stops the widget driver`() = runTest(UnconfinedTestDispatcher()) {
177+
fun `present - a received close message closes the screen and stops the widget driver`() = runTest(UnconfinedTestDispatcher()) {
178178
val navigator = FakeCallScreenNavigator()
179179
val widgetDriver = FakeMatrixWidgetDriver()
180180
val presenter = createCallScreenPresenter(
@@ -191,7 +191,7 @@ class CallScreenPresenterTest {
191191
val initialState = awaitItem()
192192
initialState.eventSink(CallScreenEvents.SetupMessageChannels(messageInterceptor))
193193

194-
messageInterceptor.givenInterceptedMessage("""{"action":"im.vector.hangup","api":"fromWidget","widgetId":"1","requestId":"1"}""")
194+
messageInterceptor.givenInterceptedMessage("""{"action":"io.element.close","api":"fromWidget","widgetId":"1","requestId":"1"}""")
195195

196196
// Let background coroutines run
197197
runCurrent()

0 commit comments

Comments
 (0)