Skip to content

Commit 1904c98

Browse files
authored
Make sure any JoinedRustRoom is destroyed after use (#4678)
1 parent 2d189ae commit 1904c98

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class CallScreenPresenter @AssistedInject constructor(
241241

242242
private suspend fun MatrixClient.notifyCallStartIfNeeded(roomId: RoomId) {
243243
if (!notifiedCallStart) {
244-
getJoinedRoom(roomId)?.sendCallNotificationIfNeeded()
244+
getJoinedRoom(roomId)?.use { it.sendCallNotificationIfNeeded() }
245245
?.onSuccess { notifiedCallStart = true }
246246
}
247247
}

features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/DefaultCallWidgetProvider.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ class DefaultCallWidgetProvider @Inject constructor(
4747
theme = theme,
4848
).getOrThrow()
4949

50+
val driver = room.getWidgetDriver(widgetSettings).getOrThrow()
51+
room.destroy()
52+
5053
CallWidgetProvider.GetWidgetResult(
51-
driver = room.getWidgetDriver(widgetSettings).getOrThrow(),
54+
driver = driver,
5255
url = callUrl,
5356
)
5457
}

features/share/impl/src/main/kotlin/io/element/android/features/share/impl/SharePresenter.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class SharePresenter @AssistedInject constructor(
8686
).isSuccess
8787
}
8888
.all { it }
89+
.also { room.destroy() }
8990
}
9091
.all { it }
9192
}

libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/JoinedRustRoom.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,11 @@ class JoinedRustRoom(
639639
}
640640
}
641641

642+
override fun close() = destroy()
643+
642644
override fun destroy() {
643645
baseRoom.destroy()
644-
liveInnerTimeline.close()
646+
liveInnerTimeline.destroy()
645647
roomCoroutineScope.cancel()
646648
}
647649

libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustBaseRoom.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ class RustBaseRoom(
9494
}
9595
}
9696

97+
override fun close() = destroy()
98+
9799
override fun destroy() {
98100
innerRoom.destroy()
99101
}

0 commit comments

Comments
 (0)