Skip to content

Commit f2bc736

Browse files
committed
fix(timeline) : dispatch timeline creations trying to avoid ANRs
1 parent 454c3ed commit f2bc736

File tree

1 file changed

+6
-6
lines changed
  • libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ class RustMatrixRoom(
191191

192192
override suspend fun subscribeToSync() = roomSyncSubscriber.subscribe(roomId)
193193

194-
override suspend fun timelineFocusedOnEvent(eventId: EventId): Result<Timeline> {
195-
return runCatching {
194+
override suspend fun timelineFocusedOnEvent(eventId: EventId): Result<Timeline> = withContext(roomDispatcher) {
195+
runCatching {
196196
innerRoom.timelineFocusedOnEvent(
197197
eventId = eventId.value,
198198
numContextEvents = 50u,
@@ -209,8 +209,8 @@ class RustMatrixRoom(
209209
}
210210
}
211211

212-
override suspend fun pinnedEventsTimeline(): Result<Timeline> {
213-
return runCatching {
212+
override suspend fun pinnedEventsTimeline(): Result<Timeline> = withContext(roomDispatcher) {
213+
runCatching {
214214
innerRoom.pinnedEventsTimeline(
215215
internalIdPrefix = "pinned_events",
216216
maxEventsToLoad = 100u,
@@ -225,8 +225,8 @@ class RustMatrixRoom(
225225
}
226226
}
227227

228-
override suspend fun mediaTimeline(): Result<Timeline> {
229-
return runCatching {
228+
override suspend fun mediaTimeline(): Result<Timeline> = withContext(roomDispatcher) {
229+
runCatching {
230230
innerRoom.messageFilteredTimeline(
231231
internalIdPrefix = "MediaGallery_",
232232
allowedMessageTypes = listOf(

0 commit comments

Comments
 (0)