Update dependency org.matrix.rustcomponents:sdk-android to v0.2.31 (#3145)
* Update dependency org.matrix.rustcomponents:sdk-android to v0.2.31 * Use new Rust client side sorting API * Make `RoomListEntriesUpdate.describe()` an extension function * Remove `RoomListSummary.Filled` and `RoomListSummary.Empty` * Fix icon sizes to pass the lint checks * Update screenshots --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jorge Martín <jorgem@element.io> Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
parent
1f69722bdd
commit
68efc918ba
46 changed files with 303 additions and 358 deletions
|
|
@ -311,7 +311,7 @@ class RustMatrixClient(
|
|||
withTimeout(timeout) {
|
||||
roomListService.allRooms.summaries
|
||||
.filter { roomSummaries ->
|
||||
roomSummaries.map { it.identifier() }.contains(roomId.value)
|
||||
roomSummaries.map { it.roomId }.contains(roomId)
|
||||
}
|
||||
.first()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2024 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.matrix.impl.roomlist
|
||||
|
||||
import org.matrix.rustcomponents.sdk.RoomListEntriesUpdate
|
||||
|
||||
internal fun RoomListEntriesUpdate.describe(): String {
|
||||
return when (this) {
|
||||
is RoomListEntriesUpdate.Set -> {
|
||||
"Set #$index to '${value.displayName()}'"
|
||||
}
|
||||
is RoomListEntriesUpdate.Append -> {
|
||||
"Append ${values.map { "'" + it.displayName() + "'" }}"
|
||||
}
|
||||
is RoomListEntriesUpdate.PushBack -> {
|
||||
"PushBack '${value.displayName()}'"
|
||||
}
|
||||
is RoomListEntriesUpdate.PushFront -> {
|
||||
"PushFront '${value.displayName()}'"
|
||||
}
|
||||
is RoomListEntriesUpdate.Insert -> {
|
||||
"Insert at #$index: '${value.displayName()}'"
|
||||
}
|
||||
is RoomListEntriesUpdate.Remove -> {
|
||||
"Remove #$index"
|
||||
}
|
||||
is RoomListEntriesUpdate.Reset -> {
|
||||
"Reset all to ${values.map { "'" + it.displayName() + "'" }}"
|
||||
}
|
||||
RoomListEntriesUpdate.PopBack -> {
|
||||
"PopBack"
|
||||
}
|
||||
RoomListEntriesUpdate.PopFront -> {
|
||||
"PopFront"
|
||||
}
|
||||
RoomListEntriesUpdate.Clear -> {
|
||||
"Clear"
|
||||
}
|
||||
is RoomListEntriesUpdate.Truncate -> {
|
||||
"Truncate to $length items"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ internal fun RoomListInterface.entriesFlow(
|
|||
}
|
||||
}
|
||||
val result = entriesWithDynamicAdapters(pageSize.toUInt(), listener)
|
||||
val controller = result.controller
|
||||
val controller = result.controller()
|
||||
controller.setFilter(initialFilterKind)
|
||||
roomListDynamicEvents.onEach { controllerEvents ->
|
||||
when (controllerEvents) {
|
||||
|
|
@ -92,7 +92,8 @@ internal fun RoomListInterface.entriesFlow(
|
|||
}
|
||||
}.launchIn(this)
|
||||
awaitClose {
|
||||
result.entriesStream.cancelAndDestroy()
|
||||
result.entriesStream().cancelAndDestroy()
|
||||
controller.destroy()
|
||||
result.destroy()
|
||||
}
|
||||
}.catch {
|
||||
|
|
|
|||
|
|
@ -26,21 +26,19 @@ val RoomListFilter.predicate
|
|||
is RoomListFilter.Any -> { _: RoomSummary -> true }
|
||||
RoomListFilter.None -> { _: RoomSummary -> false }
|
||||
RoomListFilter.Category.Group -> { roomSummary: RoomSummary ->
|
||||
roomSummary is RoomSummary.Filled && !roomSummary.details.isDirect && !roomSummary.isInvited()
|
||||
!roomSummary.isDirect && !roomSummary.isInvited()
|
||||
}
|
||||
RoomListFilter.Category.People -> { roomSummary: RoomSummary ->
|
||||
roomSummary is RoomSummary.Filled && roomSummary.details.isDirect && !roomSummary.isInvited()
|
||||
roomSummary.isDirect && !roomSummary.isInvited()
|
||||
}
|
||||
RoomListFilter.Favorite -> { roomSummary: RoomSummary ->
|
||||
roomSummary is RoomSummary.Filled && roomSummary.details.isFavorite && !roomSummary.isInvited()
|
||||
roomSummary.isFavorite && !roomSummary.isInvited()
|
||||
}
|
||||
RoomListFilter.Unread -> { roomSummary: RoomSummary ->
|
||||
roomSummary is RoomSummary.Filled &&
|
||||
!roomSummary.isInvited() &&
|
||||
(roomSummary.details.numUnreadNotifications > 0 || roomSummary.details.isMarkedUnread)
|
||||
!roomSummary.isInvited() && (roomSummary.numUnreadNotifications > 0 || roomSummary.isMarkedUnread)
|
||||
}
|
||||
is RoomListFilter.NormalizedMatchRoomName -> { roomSummary: RoomSummary ->
|
||||
roomSummary is RoomSummary.Filled && roomSummary.details.name.orEmpty().contains(pattern, ignoreCase = true)
|
||||
roomSummary.name.orEmpty().contains(pattern, ignoreCase = true)
|
||||
}
|
||||
RoomListFilter.Invite -> { roomSummary: RoomSummary ->
|
||||
roomSummary.isInvited()
|
||||
|
|
@ -61,4 +59,4 @@ fun List<RoomSummary>.filter(filter: RoomListFilter): List<RoomSummary> {
|
|||
}
|
||||
}
|
||||
|
||||
private fun RoomSummary.isInvited() = this is RoomSummary.Filled && this.details.currentUserMembership == CurrentUserMembership.INVITED
|
||||
private fun RoomSummary.isInvited() = currentUserMembership == CurrentUserMembership.INVITED
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package io.element.android.libraries.matrix.impl.roomlist
|
|||
|
||||
import io.element.android.libraries.matrix.api.core.RoomAlias
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.roomlist.RoomSummaryDetails
|
||||
import io.element.android.libraries.matrix.api.roomlist.RoomSummary
|
||||
import io.element.android.libraries.matrix.impl.notificationsettings.RoomNotificationSettingsMapper
|
||||
import io.element.android.libraries.matrix.impl.room.elementHeroes
|
||||
import io.element.android.libraries.matrix.impl.room.map
|
||||
|
|
@ -28,12 +28,12 @@ import org.matrix.rustcomponents.sdk.RoomListItem
|
|||
import org.matrix.rustcomponents.sdk.use
|
||||
|
||||
class RoomSummaryDetailsFactory(private val roomMessageFactory: RoomMessageFactory = RoomMessageFactory()) {
|
||||
suspend fun create(roomListItem: RoomListItem): RoomSummaryDetails {
|
||||
suspend fun create(roomListItem: RoomListItem): RoomSummary {
|
||||
val roomInfo = roomListItem.roomInfo()
|
||||
val latestRoomMessage = roomListItem.latestEvent()?.use {
|
||||
roomMessageFactory.create(it)
|
||||
}
|
||||
return RoomSummaryDetails(
|
||||
return RoomSummary(
|
||||
roomId = RoomId(roomInfo.id),
|
||||
name = roomInfo.displayName,
|
||||
canonicalAlias = roomInfo.canonicalAlias?.let(::RoomAlias),
|
||||
|
|
|
|||
|
|
@ -22,11 +22,10 @@ import kotlinx.coroutines.sync.Mutex
|
|||
import kotlinx.coroutines.sync.withLock
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.matrix.rustcomponents.sdk.RoomListEntriesUpdate
|
||||
import org.matrix.rustcomponents.sdk.RoomListEntry
|
||||
import org.matrix.rustcomponents.sdk.RoomListItem
|
||||
import org.matrix.rustcomponents.sdk.RoomListServiceInterface
|
||||
import org.matrix.rustcomponents.sdk.use
|
||||
import timber.log.Timber
|
||||
import java.util.UUID
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
class RoomSummaryListProcessor(
|
||||
|
|
@ -50,15 +49,17 @@ class RoomSummaryListProcessor(
|
|||
suspend fun rebuildRoomSummaries() {
|
||||
updateRoomSummaries {
|
||||
forEachIndexed { i, summary ->
|
||||
this[i] = when (summary) {
|
||||
is RoomSummary.Empty -> summary
|
||||
is RoomSummary.Filled -> buildAndCacheRoomSummaryForIdentifier(summary.identifier())
|
||||
val result = buildAndCacheRoomSummaryForIdentifier(summary.roomId.value)
|
||||
if (result != null) {
|
||||
this[i] = result
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun MutableList<RoomSummary>.applyUpdate(update: RoomListEntriesUpdate) {
|
||||
// Remove this comment to debug changes in the room list
|
||||
// Timber.d("Apply room list update: ${update.describe()}")
|
||||
when (update) {
|
||||
is RoomListEntriesUpdate.Append -> {
|
||||
val roomSummaries = update.values.map {
|
||||
|
|
@ -104,27 +105,25 @@ class RoomSummaryListProcessor(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun buildSummaryForRoomListEntry(entry: RoomListEntry): RoomSummary {
|
||||
return when (entry) {
|
||||
RoomListEntry.Empty -> buildEmptyRoomSummary()
|
||||
is RoomListEntry.Filled -> buildAndCacheRoomSummaryForIdentifier(entry.roomId)
|
||||
is RoomListEntry.Invalidated -> {
|
||||
roomSummariesByIdentifier[entry.roomId] ?: buildAndCacheRoomSummaryForIdentifier(entry.roomId)
|
||||
}
|
||||
}
|
||||
private suspend fun buildSummaryForRoomListEntry(entry: RoomListItem): RoomSummary {
|
||||
return buildAndCacheRoomSummaryForRoomListItem(entry)
|
||||
}
|
||||
|
||||
private fun buildEmptyRoomSummary(): RoomSummary {
|
||||
return RoomSummary.Empty(UUID.randomUUID().toString())
|
||||
}
|
||||
|
||||
private suspend fun buildAndCacheRoomSummaryForIdentifier(identifier: String): RoomSummary {
|
||||
private suspend fun buildAndCacheRoomSummaryForIdentifier(identifier: String): RoomSummary? {
|
||||
val builtRoomSummary = roomListService.roomOrNull(identifier)?.use { roomListItem ->
|
||||
RoomSummary.Filled(
|
||||
details = roomSummaryDetailsFactory.create(roomListItem)
|
||||
)
|
||||
} ?: buildEmptyRoomSummary()
|
||||
roomSummariesByIdentifier[builtRoomSummary.identifier()] = builtRoomSummary
|
||||
buildAndCacheRoomSummaryForRoomListItem(roomListItem)
|
||||
}
|
||||
if (builtRoomSummary != null) {
|
||||
roomSummariesByIdentifier[identifier] = builtRoomSummary
|
||||
} else {
|
||||
roomSummariesByIdentifier.remove(identifier)
|
||||
}
|
||||
return builtRoomSummary
|
||||
}
|
||||
|
||||
private suspend fun buildAndCacheRoomSummaryForRoomListItem(roomListItem: RoomListItem): RoomSummary {
|
||||
val builtRoomSummary = roomSummaryDetailsFactory.create(roomListItem = roomListItem)
|
||||
roomSummariesByIdentifier[builtRoomSummary.roomId.value] = builtRoomSummary
|
||||
return builtRoomSummary
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,6 @@ import kotlinx.coroutines.flow.distinctUntilChanged
|
|||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.rustcomponents.sdk.RoomListException
|
||||
import org.matrix.rustcomponents.sdk.RoomListInput
|
||||
import org.matrix.rustcomponents.sdk.RoomListRange
|
||||
import org.matrix.rustcomponents.sdk.RoomListServiceState
|
||||
import org.matrix.rustcomponents.sdk.RoomListServiceSyncIndicator
|
||||
import timber.log.Timber
|
||||
|
|
@ -73,20 +69,6 @@ internal class RustRoomListService(
|
|||
allRooms.loadAllIncrementally(sessionCoroutineScope)
|
||||
}
|
||||
|
||||
override fun updateAllRoomsVisibleRange(range: IntRange) {
|
||||
Timber.v("setVisibleRange=$range")
|
||||
sessionCoroutineScope.launch {
|
||||
try {
|
||||
val ranges = listOf(RoomListRange(range.first.toUInt(), range.last.toUInt()))
|
||||
innerRoomListService.applyInput(
|
||||
RoomListInput.Viewport(ranges)
|
||||
)
|
||||
} catch (exception: RoomListException) {
|
||||
Timber.e(exception, "Failed updating visible range")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override val syncIndicator: StateFlow<RoomListService.SyncIndicator> =
|
||||
innerRoomListService.syncIndicator()
|
||||
.map { it.toSyncIndicator() }
|
||||
|
|
|
|||
|
|
@ -19,46 +19,31 @@ package io.element.android.libraries.matrix.impl.roomlist
|
|||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.matrix.api.room.CurrentUserMembership
|
||||
import io.element.android.libraries.matrix.api.roomlist.RoomListFilter
|
||||
import io.element.android.libraries.matrix.test.room.aRoomSummaryDetails
|
||||
import io.element.android.libraries.matrix.test.room.aRoomSummaryFilled
|
||||
import io.element.android.libraries.matrix.test.room.aRoomSummary
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
|
||||
class RoomListFilterTest {
|
||||
private val regularRoom = aRoomSummaryFilled(
|
||||
aRoomSummaryDetails(
|
||||
isDirect = false
|
||||
)
|
||||
private val regularRoom = aRoomSummary(
|
||||
isDirect = false
|
||||
)
|
||||
private val directRoom = aRoomSummaryFilled(
|
||||
aRoomSummaryDetails(
|
||||
isDirect = true
|
||||
)
|
||||
private val directRoom = aRoomSummary(
|
||||
isDirect = true
|
||||
)
|
||||
private val favoriteRoom = aRoomSummaryFilled(
|
||||
aRoomSummaryDetails(
|
||||
isFavorite = true
|
||||
)
|
||||
private val favoriteRoom = aRoomSummary(
|
||||
isFavorite = true
|
||||
)
|
||||
private val markedAsUnreadRoom = aRoomSummaryFilled(
|
||||
aRoomSummaryDetails(
|
||||
isMarkedUnread = true
|
||||
)
|
||||
private val markedAsUnreadRoom = aRoomSummary(
|
||||
isMarkedUnread = true
|
||||
)
|
||||
private val unreadNotificationRoom = aRoomSummaryFilled(
|
||||
aRoomSummaryDetails(
|
||||
numUnreadNotifications = 1
|
||||
)
|
||||
private val unreadNotificationRoom = aRoomSummary(
|
||||
numUnreadNotifications = 1
|
||||
)
|
||||
private val roomToSearch = aRoomSummaryFilled(
|
||||
aRoomSummaryDetails(
|
||||
name = "Room to search"
|
||||
)
|
||||
private val roomToSearch = aRoomSummary(
|
||||
name = "Room to search"
|
||||
)
|
||||
private val invitedRoom = aRoomSummaryFilled(
|
||||
aRoomSummaryDetails(
|
||||
currentUserMembership = CurrentUserMembership.INVITED
|
||||
)
|
||||
private val invitedRoom = aRoomSummary(
|
||||
currentUserMembership = CurrentUserMembership.INVITED
|
||||
)
|
||||
|
||||
private val roomSummaries = listOf(
|
||||
|
|
|
|||
|
|
@ -18,23 +18,31 @@ package io.element.android.libraries.matrix.impl.roomlist
|
|||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.sun.jna.Pointer
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.roomlist.RoomSummary
|
||||
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||
import io.element.android.libraries.matrix.test.A_ROOM_ID_2
|
||||
import io.element.android.libraries.matrix.test.A_ROOM_NAME
|
||||
import io.element.android.libraries.matrix.test.room.aRoomSummary
|
||||
import io.element.android.libraries.matrix.test.room.aRoomSummaryFilled
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.test.StandardTestDispatcher
|
||||
import kotlinx.coroutines.test.TestScope
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
import org.matrix.rustcomponents.sdk.EventTimelineItem
|
||||
import org.matrix.rustcomponents.sdk.Membership
|
||||
import org.matrix.rustcomponents.sdk.NoPointer
|
||||
import org.matrix.rustcomponents.sdk.RoomHero
|
||||
import org.matrix.rustcomponents.sdk.RoomInfo
|
||||
import org.matrix.rustcomponents.sdk.RoomList
|
||||
import org.matrix.rustcomponents.sdk.RoomListEntriesUpdate
|
||||
import org.matrix.rustcomponents.sdk.RoomListEntry
|
||||
import org.matrix.rustcomponents.sdk.RoomListInput
|
||||
import org.matrix.rustcomponents.sdk.RoomListItem
|
||||
import org.matrix.rustcomponents.sdk.RoomListServiceInterface
|
||||
import org.matrix.rustcomponents.sdk.RoomListServiceStateListener
|
||||
import org.matrix.rustcomponents.sdk.RoomListServiceSyncIndicatorListener
|
||||
import org.matrix.rustcomponents.sdk.RoomMember
|
||||
import org.matrix.rustcomponents.sdk.RoomNotificationMode
|
||||
import org.matrix.rustcomponents.sdk.TaskHandle
|
||||
|
||||
// NOTE: this class is using a fake implementation of a Rust SDK interface which returns actual Rust objects with pointers.
|
||||
|
|
@ -44,33 +52,34 @@ class RoomSummaryListProcessorTest {
|
|||
|
||||
@Test
|
||||
fun `Append adds new entries at the end of the list`() = runTest {
|
||||
summaries.value = listOf(aRoomSummaryFilled())
|
||||
summaries.value = listOf(aRoomSummary())
|
||||
val processor = createProcessor()
|
||||
|
||||
processor.postUpdate(listOf(RoomListEntriesUpdate.Append(listOf(RoomListEntry.Empty, RoomListEntry.Empty, RoomListEntry.Empty))))
|
||||
val newEntry = FakeRoomListItem(A_ROOM_ID_2)
|
||||
processor.postUpdate(listOf(RoomListEntriesUpdate.Append(listOf(newEntry, newEntry, newEntry))))
|
||||
|
||||
assertThat(summaries.value.count()).isEqualTo(4)
|
||||
assertThat(summaries.value.subList(1, 4).all { it is RoomSummary.Empty }).isTrue()
|
||||
assertThat(summaries.value.subList(1, 4).all { it.roomId == A_ROOM_ID_2 }).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `PushBack adds a new entry at the end of the list`() = runTest {
|
||||
summaries.value = listOf(aRoomSummaryFilled())
|
||||
val processor = createProcessor()
|
||||
processor.postUpdate(listOf(RoomListEntriesUpdate.PushBack(RoomListEntry.Empty)))
|
||||
processor.postUpdate(listOf(RoomListEntriesUpdate.PushBack(FakeRoomListItem(A_ROOM_ID_2))))
|
||||
|
||||
assertThat(summaries.value.count()).isEqualTo(2)
|
||||
assertThat(summaries.value.last()).isInstanceOf(RoomSummary.Empty::class.java)
|
||||
assertThat(summaries.value.last().roomId).isEqualTo(A_ROOM_ID_2)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `PushFront inserts a new entry at the start of the list`() = runTest {
|
||||
summaries.value = listOf(aRoomSummaryFilled())
|
||||
val processor = createProcessor()
|
||||
processor.postUpdate(listOf(RoomListEntriesUpdate.PushFront(RoomListEntry.Empty)))
|
||||
processor.postUpdate(listOf(RoomListEntriesUpdate.PushFront(FakeRoomListItem(A_ROOM_ID_2))))
|
||||
|
||||
assertThat(summaries.value.count()).isEqualTo(2)
|
||||
assertThat(summaries.value.first()).isInstanceOf(RoomSummary.Empty::class.java)
|
||||
assertThat(summaries.value.first().roomId).isEqualTo(A_ROOM_ID_2)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -79,10 +88,10 @@ class RoomSummaryListProcessorTest {
|
|||
val processor = createProcessor()
|
||||
val index = 0
|
||||
|
||||
processor.postUpdate(listOf(RoomListEntriesUpdate.Set(index.toUInt(), RoomListEntry.Empty)))
|
||||
processor.postUpdate(listOf(RoomListEntriesUpdate.Set(index.toUInt(), FakeRoomListItem(A_ROOM_ID_2))))
|
||||
|
||||
assertThat(summaries.value.count()).isEqualTo(1)
|
||||
assertThat(summaries.value[index]).isInstanceOf(RoomSummary.Empty::class.java)
|
||||
assertThat(summaries.value[index].roomId).isEqualTo(A_ROOM_ID_2)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -91,10 +100,10 @@ class RoomSummaryListProcessorTest {
|
|||
val processor = createProcessor()
|
||||
val index = 0
|
||||
|
||||
processor.postUpdate(listOf(RoomListEntriesUpdate.Insert(index.toUInt(), RoomListEntry.Empty)))
|
||||
processor.postUpdate(listOf(RoomListEntriesUpdate.Insert(index.toUInt(), FakeRoomListItem(A_ROOM_ID_2))))
|
||||
|
||||
assertThat(summaries.value.count()).isEqualTo(2)
|
||||
assertThat(summaries.value[index]).isInstanceOf(RoomSummary.Empty::class.java)
|
||||
assertThat(summaries.value[index].roomId).isEqualTo(A_ROOM_ID_2)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -106,7 +115,7 @@ class RoomSummaryListProcessorTest {
|
|||
processor.postUpdate(listOf(RoomListEntriesUpdate.Remove(index.toUInt())))
|
||||
|
||||
assertThat(summaries.value.count()).isEqualTo(1)
|
||||
assertThat((summaries.value[index] as RoomSummary.Filled).identifier()).isEqualTo(A_ROOM_ID_2.value)
|
||||
assertThat(summaries.value[index].roomId).isEqualTo(A_ROOM_ID_2)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -118,7 +127,7 @@ class RoomSummaryListProcessorTest {
|
|||
processor.postUpdate(listOf(RoomListEntriesUpdate.PopBack))
|
||||
|
||||
assertThat(summaries.value.count()).isEqualTo(1)
|
||||
assertThat((summaries.value[index] as RoomSummary.Filled).identifier()).isEqualTo(A_ROOM_ID.value)
|
||||
assertThat(summaries.value[index].roomId).isEqualTo(A_ROOM_ID)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -130,7 +139,7 @@ class RoomSummaryListProcessorTest {
|
|||
processor.postUpdate(listOf(RoomListEntriesUpdate.PopFront))
|
||||
|
||||
assertThat(summaries.value.count()).isEqualTo(1)
|
||||
assertThat((summaries.value[index] as RoomSummary.Filled).identifier()).isEqualTo(A_ROOM_ID_2.value)
|
||||
assertThat(summaries.value[index].roomId).isEqualTo(A_ROOM_ID_2)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -152,7 +161,7 @@ class RoomSummaryListProcessorTest {
|
|||
processor.postUpdate(listOf(RoomListEntriesUpdate.Truncate(1u)))
|
||||
|
||||
assertThat(summaries.value.count()).isEqualTo(1)
|
||||
assertThat((summaries.value[index] as RoomSummary.Filled).identifier()).isEqualTo(A_ROOM_ID.value)
|
||||
assertThat(summaries.value[index].roomId).isEqualTo(A_ROOM_ID)
|
||||
}
|
||||
|
||||
private fun TestScope.createProcessor() = RoomSummaryListProcessor(
|
||||
|
|
@ -168,8 +177,6 @@ class RoomSummaryListProcessorTest {
|
|||
return RoomList(Pointer.NULL)
|
||||
}
|
||||
|
||||
override suspend fun applyInput(input: RoomListInput) = Unit
|
||||
|
||||
override fun room(roomId: String): RoomListItem {
|
||||
return RoomListItem(Pointer.NULL)
|
||||
}
|
||||
|
|
@ -183,3 +190,81 @@ class RoomSummaryListProcessorTest {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun aRustRoomInfo(
|
||||
id: String = A_ROOM_ID.value,
|
||||
displayName: String = A_ROOM_NAME,
|
||||
rawName: String = A_ROOM_NAME,
|
||||
topic: String? = null,
|
||||
avatarUrl: String? = null,
|
||||
isDirect: Boolean = false,
|
||||
isPublic: Boolean = false,
|
||||
isSpace: Boolean = false,
|
||||
isTombstoned: Boolean = false,
|
||||
isFavourite: Boolean = false,
|
||||
canonicalAlias: String? = null,
|
||||
alternativeAliases: List<String> = listOf(),
|
||||
membership: Membership = Membership.JOINED,
|
||||
inviter: RoomMember? = null,
|
||||
heroes: List<RoomHero> = listOf(),
|
||||
activeMembersCount: ULong = 0uL,
|
||||
invitedMembersCount: ULong = 0uL,
|
||||
joinedMembersCount: ULong = 0uL,
|
||||
userPowerLevels: Map<String, Long> = mapOf(),
|
||||
highlightCount: ULong = 0uL,
|
||||
notificationCount: ULong = 0uL,
|
||||
userDefinedNotificationMode: RoomNotificationMode? = null,
|
||||
hasRoomCall: Boolean = false,
|
||||
activeRoomCallParticipants: List<String> = listOf(),
|
||||
isMarkedUnread: Boolean = false,
|
||||
numUnreadMessages: ULong = 0uL,
|
||||
numUnreadNotifications: ULong = 0uL,
|
||||
numUnreadMentions: ULong = 0uL,
|
||||
) = RoomInfo(
|
||||
id = id,
|
||||
displayName = displayName,
|
||||
rawName = rawName,
|
||||
topic = topic,
|
||||
avatarUrl = avatarUrl,
|
||||
isDirect = isDirect,
|
||||
isPublic = isPublic,
|
||||
isSpace = isSpace,
|
||||
isTombstoned = isTombstoned,
|
||||
isFavourite = isFavourite,
|
||||
canonicalAlias = canonicalAlias,
|
||||
alternativeAliases = alternativeAliases,
|
||||
membership = membership,
|
||||
inviter = inviter,
|
||||
heroes = heroes,
|
||||
activeMembersCount = activeMembersCount,
|
||||
invitedMembersCount = invitedMembersCount,
|
||||
joinedMembersCount = joinedMembersCount,
|
||||
userPowerLevels = userPowerLevels,
|
||||
highlightCount = highlightCount,
|
||||
notificationCount = notificationCount,
|
||||
userDefinedNotificationMode = userDefinedNotificationMode,
|
||||
hasRoomCall = hasRoomCall,
|
||||
activeRoomCallParticipants = activeRoomCallParticipants,
|
||||
isMarkedUnread = isMarkedUnread,
|
||||
numUnreadMessages = numUnreadMessages,
|
||||
numUnreadNotifications = numUnreadNotifications,
|
||||
numUnreadMentions = numUnreadMentions
|
||||
)
|
||||
|
||||
class FakeRoomListItem(
|
||||
private val roomId: RoomId,
|
||||
private val roomInfo: RoomInfo = aRustRoomInfo(id = roomId.value),
|
||||
private val latestEvent: EventTimelineItem? = null,
|
||||
) : RoomListItem(NoPointer) {
|
||||
override fun id(): String {
|
||||
return roomId.value
|
||||
}
|
||||
|
||||
override suspend fun roomInfo(): RoomInfo {
|
||||
return roomInfo
|
||||
}
|
||||
|
||||
override suspend fun latestEvent(): EventTimelineItem? {
|
||||
return latestEvent
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue