Room directory : add tests and cleanup
This commit is contained in:
parent
37d645d153
commit
3f1f764745
27 changed files with 573 additions and 77 deletions
|
|
@ -76,7 +76,6 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
|
|||
import kotlinx.coroutines.TimeoutCancellationException
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
|
@ -441,7 +440,7 @@ class RustMatrixClient(
|
|||
runCatching { client.removeAvatar() }
|
||||
}
|
||||
|
||||
override suspend fun joinRoom(roomId: RoomId): Result<RoomId> = withContext(sessionDispatcher) {
|
||||
override suspend fun joinRoom(roomId: RoomId): Result<RoomId> = withContext(sessionDispatcher) {
|
||||
runCatching {
|
||||
client.joinRoomById(roomId.value).destroy()
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import org.matrix.rustcomponents.sdk.PublicRoomJoinRule
|
|||
import org.matrix.rustcomponents.sdk.RoomDescription as RustRoomDescription
|
||||
|
||||
class RoomDescriptionMapper {
|
||||
|
||||
fun map(roomDescription: RustRoomDescription): RoomDescription {
|
||||
return RoomDescription(
|
||||
roomId = RoomId(roomDescription.roomId),
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class RoomDirectorySearchProcessor(
|
|||
private val coroutineContext: CoroutineContext,
|
||||
private val roomDescriptionMapper: RoomDescriptionMapper,
|
||||
) {
|
||||
|
||||
private val mutex = Mutex()
|
||||
|
||||
suspend fun postUpdates(updates: List<RoomDirectorySearchEntryUpdate>) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ class RustRoomDirectoryList(
|
|||
coroutineScope: CoroutineScope,
|
||||
private val coroutineContext: CoroutineContext,
|
||||
) : RoomDirectoryList {
|
||||
|
||||
private val hasMoreToLoad = MutableStateFlow(true)
|
||||
private val items = MutableSharedFlow<List<RoomDescription>>(replay = 1)
|
||||
private val processor = RoomDirectorySearchProcessor(items, coroutineContext, RoomDescriptionMapper())
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ class RustRoomDirectoryService(
|
|||
private val client: Client,
|
||||
private val sessionDispatcher: CoroutineDispatcher,
|
||||
) : RoomDirectoryService {
|
||||
|
||||
override fun createRoomDirectoryList(scope: CoroutineScope): RoomDirectoryList {
|
||||
return RustRoomDirectoryList(client.roomDirectorySearch(), scope, sessionDispatcher)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue