sdk : allow passing coroutineScope to RoomList
This commit is contained in:
parent
a1b81046f0
commit
e6d8b07538
15 changed files with 83 additions and 35 deletions
|
|
@ -192,7 +192,6 @@ class RustMatrixClient(
|
|||
sessionDispatcher = sessionDispatcher,
|
||||
roomListFactory = RoomListFactory(
|
||||
innerRoomListService = innerRoomListService,
|
||||
sessionCoroutineScope = sessionCoroutineScope,
|
||||
analyticsService = analyticsService,
|
||||
),
|
||||
roomSyncSubscriber = roomSyncSubscriber,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ private val ROOM_LIST_RUST_FILTERS = listOf(
|
|||
|
||||
internal class RoomListFactory(
|
||||
private val innerRoomListService: RoomListService,
|
||||
private val sessionCoroutineScope: CoroutineScope,
|
||||
private val analyticsService: AnalyticsService,
|
||||
) {
|
||||
private val roomSummaryFactory: RoomSummaryFactory = RoomSummaryFactory()
|
||||
|
|
@ -49,7 +48,7 @@ internal class RoomListFactory(
|
|||
fun createRoomList(
|
||||
pageSize: Int,
|
||||
coroutineContext: CoroutineContext,
|
||||
coroutineScope: CoroutineScope = sessionCoroutineScope,
|
||||
coroutineScope: CoroutineScope,
|
||||
initialFilter: RoomListFilter = RoomListFilter.all(),
|
||||
innerProvider: suspend () -> InnerRoomList
|
||||
): DynamicRoomList {
|
||||
|
|
|
|||
|
|
@ -35,17 +35,19 @@ internal class RustRoomListService(
|
|||
private val sessionDispatcher: CoroutineDispatcher,
|
||||
private val roomListFactory: RoomListFactory,
|
||||
private val roomSyncSubscriber: RoomSyncSubscriber,
|
||||
sessionCoroutineScope: CoroutineScope,
|
||||
private val sessionCoroutineScope: CoroutineScope,
|
||||
) : RoomListService {
|
||||
override fun createRoomList(
|
||||
pageSize: Int,
|
||||
initialFilter: RoomListFilter,
|
||||
source: RoomList.Source
|
||||
source: RoomList.Source,
|
||||
coroutineScope: CoroutineScope,
|
||||
): DynamicRoomList {
|
||||
return roomListFactory.createRoomList(
|
||||
pageSize = pageSize,
|
||||
initialFilter = initialFilter,
|
||||
coroutineContext = sessionDispatcher,
|
||||
coroutineScope = coroutineScope,
|
||||
) {
|
||||
when (source) {
|
||||
RoomList.Source.All -> innerRoomListService.allRooms()
|
||||
|
|
@ -60,6 +62,7 @@ internal class RustRoomListService(
|
|||
override val allRooms: DynamicRoomList = roomListFactory.createRoomList(
|
||||
pageSize = DEFAULT_PAGE_SIZE,
|
||||
coroutineContext = sessionDispatcher,
|
||||
coroutineScope = sessionCoroutineScope,
|
||||
) {
|
||||
innerRoomListService.allRooms()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ class RoomListFactoryTest {
|
|||
fun `createRoomList should work`() = runTest {
|
||||
val sut = RoomListFactory(
|
||||
innerRoomListService = FakeFfiRoomListService(),
|
||||
sessionCoroutineScope = backgroundScope,
|
||||
analyticsService = FakeAnalyticsService(),
|
||||
)
|
||||
sut.createRoomList(
|
||||
pageSize = 10,
|
||||
coroutineContext = EmptyCoroutineContext,
|
||||
coroutineScope = backgroundScope,
|
||||
) {
|
||||
FakeFfiRoomList()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ private fun TestScope.createRustRoomListService(
|
|||
sessionDispatcher = StandardTestDispatcher(testScheduler),
|
||||
roomListFactory = RoomListFactory(
|
||||
innerRoomListService = roomListService,
|
||||
sessionCoroutineScope = backgroundScope,
|
||||
analyticsService = FakeAnalyticsService(),
|
||||
),
|
||||
roomSyncSubscriber = RoomSyncSubscriber(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue