Clean up unused imports and improve code documentation

This commit is contained in:
ganfra 2026-01-27 18:43:21 +01:00
parent 44d33af6dc
commit a85c566341
7 changed files with 14 additions and 21 deletions

View file

@ -35,7 +35,6 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.seconds
@Inject
class AddRoomToSpacePresenter(

View file

@ -16,14 +16,14 @@ import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.matrix.api.room.CurrentUserMembership
import io.element.android.libraries.matrix.api.room.RoomInfo
import io.element.android.libraries.matrix.api.room.isDm
import io.element.android.libraries.matrix.ui.model.SelectRoomInfo
import io.element.android.libraries.matrix.ui.model.toSelectRoomInfo
import io.element.android.libraries.matrix.api.room.recent.getRecentlyVisitedRoomInfoFlow
import io.element.android.libraries.matrix.api.roomlist.RoomList
import io.element.android.libraries.matrix.api.roomlist.RoomListFilter
import io.element.android.libraries.matrix.api.roomlist.RoomListService
import io.element.android.libraries.matrix.api.roomlist.loadAllIncrementally
import io.element.android.libraries.matrix.api.spaces.SpaceRoomList
import io.element.android.libraries.matrix.ui.model.SelectRoomInfo
import io.element.android.libraries.matrix.ui.model.toSelectRoomInfo
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.CoroutineScope
@ -67,15 +67,15 @@ class AddRoomToSpaceSearchDataSource(
rooms.map { it.roomId }.toSet()
}
// Track locally added rooms for partial failure cases
private val addedRoomIds = MutableStateFlow<Set<RoomId>>(emptySet())
// Track locally added rooms for partial success handling.
// These rooms will be filtered out from search results and suggestions.
private val addedRoomIdsFlow = MutableStateFlow<Set<RoomId>>(emptySet())
/**
* Marks rooms as added to the space (for partial failure handling).
* These rooms will be filtered out from search results and suggestions.
* Marks rooms as added to the space (for partial success handling).
*/
fun markAsAdded(roomIds: Set<RoomId>) {
addedRoomIds.value += roomIds
addedRoomIdsFlow.value += roomIds
}
private val filterRoomPredicate: (RoomInfo, Set<RoomId>, Set<RoomId>) -> Boolean = { info, childIds, addedIds ->
@ -89,7 +89,7 @@ class AddRoomToSpaceSearchDataSource(
val roomInfoList: Flow<ImmutableList<SelectRoomInfo>> = combine(
roomList.filteredSummaries,
spaceChildrenFlow,
addedRoomIds,
addedRoomIdsFlow,
) { roomSummaries, childIds, addedIds ->
roomSummaries
.filter { filterRoomPredicate(it.info, childIds, addedIds) }
@ -99,7 +99,7 @@ class AddRoomToSpaceSearchDataSource(
val suggestions: Flow<ImmutableList<SelectRoomInfo>> = combine(
spaceChildrenFlow,
addedRoomIds,
addedRoomIdsFlow,
) { childIds, addedIds ->
matrixClient
.getRecentlyVisitedRoomInfoFlow { filterRoomPredicate(it, childIds, addedIds) }

View file

@ -25,12 +25,12 @@ import io.element.android.libraries.matrix.test.spaces.FakeSpaceRoomList
import io.element.android.libraries.matrix.test.spaces.FakeSpaceService
import io.element.android.libraries.matrix.ui.components.aSelectRoomInfo
import io.element.android.libraries.matrix.ui.model.SelectRoomInfo
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import io.element.android.tests.testutils.lambda.assert
import io.element.android.tests.testutils.lambda.lambdaRecorder
import io.element.android.tests.testutils.test
import io.element.android.tests.testutils.testCoroutineDispatchers
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestScope

View file

@ -20,7 +20,7 @@ import io.element.android.tests.testutils.EventsRecorder
import io.element.android.tests.testutils.clickOn
import io.element.android.tests.testutils.ensureCalledOnce
import io.element.android.tests.testutils.pressBack
import kotlinx.collections.immutable.toPersistentList
import kotlinx.collections.immutable.toImmutableList
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TestRule
@ -65,7 +65,7 @@ class AddRoomToSpaceViewTest {
val eventsRecorder = EventsRecorder<AddRoomToSpaceEvent>()
rule.setAddRoomToSpaceView(
anAddRoomToSpaceState(
selectedRooms = aSelectRoomInfoList().take(1).toPersistentList(),
selectedRooms = aSelectRoomInfoList().take(1).toImmutableList(),
eventSink = eventsRecorder,
),
)

View file

@ -30,7 +30,6 @@ import io.element.android.libraries.matrix.api.room.CurrentUserMembership
import io.element.android.libraries.matrix.api.room.RoomType
import io.element.android.libraries.matrix.api.room.join.JoinRoom
import io.element.android.libraries.matrix.api.spaces.SpaceRoomList
import io.element.android.libraries.matrix.api.spaces.loadAllIncrementally
import io.element.android.libraries.matrix.test.AN_EXCEPTION
import io.element.android.libraries.matrix.test.A_ROOM_ID
import io.element.android.libraries.matrix.test.A_ROOM_ID_2
@ -50,7 +49,6 @@ import io.element.android.tests.testutils.test
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Test
import im.vector.app.features.analytics.plan.JoinedRoom as AnalyticsJoinedRoom
@ -393,7 +391,7 @@ class SpacePresenterTest {
val removeChildFromSpaceResult = lambdaRecorder<RoomId, RoomId, Result<Unit>> { _, _ ->
Result.success(Unit)
}
val resetResult = lambdaRecorder<Result<Unit>> { Result.success(Unit) }
val resetResult = lambdaRecorder<Result<Unit>> { Result.success(Unit) }
val aRoom = aSpaceRoom(
roomId = A_ROOM_ID,
roomType = RoomType.Room,

View file

@ -12,12 +12,9 @@ import io.element.android.libraries.matrix.api.core.RoomId
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.withTimeoutOrNull
import java.util.Optional
import kotlin.time.Duration
interface SpaceRoomList {
sealed interface PaginationStatus {

View file

@ -17,7 +17,6 @@ import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.launchIn