mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-28 01:49:23 +01:00
Fix / summary showing roomIds instead of names
This commit is contained in:
parent
c01b36a648
commit
acf7a226f0
@ -29,7 +29,9 @@ data class SpaceManageRoomViewState(
|
||||
val selectedRooms: List<String> = emptyList(),
|
||||
val currentFilter: String = "",
|
||||
val actionState: Async<Unit> = Uninitialized,
|
||||
val paginationStatus: Async<Unit> = Uninitialized
|
||||
val paginationStatus: Async<Unit> = Uninitialized,
|
||||
// cached room summaries of known rooms, we use it because computed room name would be better using it
|
||||
val knownRoomSummaries : List<RoomSummary> = emptyList()
|
||||
) : MvRxState {
|
||||
constructor(args: SpaceManageArgs) : this(
|
||||
spaceId = args.spaceId
|
||||
|
@ -80,7 +80,10 @@ class SpaceManageRoomsController @Inject constructor(
|
||||
filteredResult.forEach { childInfo ->
|
||||
roomManageSelectionItem {
|
||||
id(childInfo.childRoomId)
|
||||
matrixItem(childInfo.toMatrixItem())
|
||||
matrixItem(
|
||||
data.knownRoomSummaries.firstOrNull { it.roomId == childInfo.childRoomId }?.toMatrixItem()
|
||||
?: childInfo.toMatrixItem()
|
||||
)
|
||||
avatarRenderer(host.avatarRenderer)
|
||||
suggested(childInfo.suggested ?: false)
|
||||
selected(data.selectedRooms.contains(childInfo.childRoomId))
|
||||
|
@ -51,9 +51,7 @@ class SpaceManageRoomsViewModel @AssistedInject constructor(
|
||||
)
|
||||
}
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
refreshSummaryAPI()
|
||||
}
|
||||
refreshSummaryAPI()
|
||||
}
|
||||
|
||||
@AssistedFactory
|
||||
@ -163,7 +161,10 @@ class SpaceManageRoomsViewModel @AssistedInject constructor(
|
||||
setState {
|
||||
copy(
|
||||
childrenInfo = apiResult,
|
||||
paginationStatus = Uninitialized
|
||||
paginationStatus = Uninitialized,
|
||||
knownRoomSummaries = apiResult.invoke()?.children?.mapNotNull {
|
||||
session.getRoomSummary(it.childRoomId)
|
||||
}.orEmpty()
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -195,6 +196,7 @@ class SpaceManageRoomsViewModel @AssistedInject constructor(
|
||||
knownStateList = knownResults.childrenState.orEmpty(),
|
||||
limit = paginationLimit
|
||||
)
|
||||
val newKnown = apiResult.children.mapNotNull { session.getRoomSummary(it.childRoomId) }
|
||||
setState {
|
||||
copy(
|
||||
childrenInfo = Success(
|
||||
@ -203,7 +205,8 @@ class SpaceManageRoomsViewModel @AssistedInject constructor(
|
||||
nextToken = apiResult.nextToken
|
||||
)
|
||||
),
|
||||
paginationStatus = Success(Unit)
|
||||
paginationStatus = Success(Unit),
|
||||
knownRoomSummaries = (state.knownRoomSummaries + newKnown).distinctBy { it.roomId }
|
||||
)
|
||||
}
|
||||
} catch (failure: Throwable) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user