Ensure that the Rust room is not closed while the driver needs it. (#4694)
This commit is contained in:
parent
62a1d1bcb9
commit
0e74fe7062
3 changed files with 4 additions and 1 deletions
|
|
@ -48,7 +48,6 @@ class DefaultCallWidgetProvider @Inject constructor(
|
||||||
).getOrThrow()
|
).getOrThrow()
|
||||||
|
|
||||||
val driver = room.getWidgetDriver(widgetSettings).getOrThrow()
|
val driver = room.getWidgetDriver(widgetSettings).getOrThrow()
|
||||||
room.destroy()
|
|
||||||
|
|
||||||
CallWidgetProvider.GetWidgetResult(
|
CallWidgetProvider.GetWidgetResult(
|
||||||
driver = driver,
|
driver = driver,
|
||||||
|
|
|
||||||
|
|
@ -595,6 +595,7 @@ class JoinedRustRoom(
|
||||||
RustWidgetDriver(
|
RustWidgetDriver(
|
||||||
widgetSettings = widgetSettings,
|
widgetSettings = widgetSettings,
|
||||||
room = innerRoom,
|
room = innerRoom,
|
||||||
|
joinedRustRoom = this,
|
||||||
widgetCapabilitiesProvider = object : WidgetCapabilitiesProvider {
|
widgetCapabilitiesProvider = object : WidgetCapabilitiesProvider {
|
||||||
override fun acquireCapabilities(capabilities: WidgetCapabilities): WidgetCapabilities {
|
override fun acquireCapabilities(capabilities: WidgetCapabilities): WidgetCapabilities {
|
||||||
return getElementCallRequiredPermissions(sessionId.value, baseRoom.deviceId.value)
|
return getElementCallRequiredPermissions(sessionId.value, baseRoom.deviceId.value)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ package io.element.android.libraries.matrix.impl.widget
|
||||||
|
|
||||||
import io.element.android.libraries.matrix.api.widget.MatrixWidgetDriver
|
import io.element.android.libraries.matrix.api.widget.MatrixWidgetDriver
|
||||||
import io.element.android.libraries.matrix.api.widget.MatrixWidgetSettings
|
import io.element.android.libraries.matrix.api.widget.MatrixWidgetSettings
|
||||||
|
import io.element.android.libraries.matrix.impl.room.JoinedRustRoom
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
|
|
@ -24,6 +25,7 @@ import kotlin.coroutines.coroutineContext
|
||||||
class RustWidgetDriver(
|
class RustWidgetDriver(
|
||||||
widgetSettings: MatrixWidgetSettings,
|
widgetSettings: MatrixWidgetSettings,
|
||||||
private val room: Room,
|
private val room: Room,
|
||||||
|
private val joinedRustRoom: JoinedRustRoom,
|
||||||
private val widgetCapabilitiesProvider: WidgetCapabilitiesProvider,
|
private val widgetCapabilitiesProvider: WidgetCapabilitiesProvider,
|
||||||
) : MatrixWidgetDriver {
|
) : MatrixWidgetDriver {
|
||||||
// It's important to have extra capacity here to make sure we don't drop any messages
|
// It's important to have extra capacity here to make sure we don't drop any messages
|
||||||
|
|
@ -69,5 +71,6 @@ class RustWidgetDriver(
|
||||||
override fun close() {
|
override fun close() {
|
||||||
receiveMessageJob?.cancel()
|
receiveMessageJob?.cancel()
|
||||||
driverAndHandle.driver.close()
|
driverAndHandle.driver.close()
|
||||||
|
joinedRustRoom.destroy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue