avoiding sync event updates from other rooms

This commit is contained in:
Adam Brown 2022-10-01 13:07:37 +01:00 committed by Adam Brown
parent 03cb954ea8
commit 74dff9ccf2
2 changed files with 5 additions and 3 deletions

View File

@ -19,7 +19,7 @@ interface SyncService : MatrixService {
fun overview(): Flow<OverviewState>
fun room(roomId: RoomId): Flow<RoomState>
fun startSyncing(): Flow<Unit>
fun events(): Flow<List<SyncEvent>>
fun events(roomId: RoomId? = null): Flow<List<SyncEvent>>
suspend fun observeEvent(eventId: EventId): Flow<EventId>
suspend fun forceManualRefresh(roomIds: List<RoomId>)
@ -27,7 +27,9 @@ interface SyncService : MatrixService {
value class FilterId(val value: String)
sealed interface SyncEvent {
data class Typing(val roomId: RoomId, val members: List<RoomMember>) : SyncEvent
val roomId: RoomId
data class Typing(override val roomId: RoomId, val members: List<RoomMember>) : SyncEvent
}
}

View File

@ -108,7 +108,7 @@ internal class DefaultSyncService(
override fun invites() = overviewStore.latestInvites()
override fun overview() = overviewStore.latest()
override fun room(roomId: RoomId) = roomStore.latest(roomId)
override fun events() = syncEventsFlow
override fun events(roomId: RoomId?) = roomId?.let { syncEventsFlow.map { it.filter { it.roomId == roomId } }.distinctUntilChanged() } ?: syncEventsFlow
override suspend fun observeEvent(eventId: EventId) = roomStore.observeEvent(eventId)
override suspend fun forceManualRefresh(roomIds: List<RoomId>) {
coroutineDispatchers.withIoContext {