Selection state should be tested through room id

This commit is contained in:
ganfra 2018-10-29 17:54:45 +01:00
parent 7dc7b4b8eb
commit e06d95b8e3
3 changed files with 7 additions and 6 deletions

View File

@ -79,7 +79,7 @@ class RoomListFragment : RiotFragment(), RoomSummaryController.Callback {

override fun onRoomSelected(room: RoomSummary) {
withState(viewModel) {
if (it.selectedRoom != room) {
if (it.selectedRoom?.roomId != room.roomId) {
viewModel.accept(RoomListActions.SelectRoom(room))
homeNavigator.openRoomDetail(room.roomId)
}

View File

@ -7,14 +7,15 @@ import im.vector.matrix.android.api.session.room.model.RoomSummary

data class RoomListViewState(
val roomSummaries: Async<List<RoomSummary>> = Uninitialized,
val selectedRoom: RoomSummary? = null
val selectedRoom: RoomSummary? = null,
private var _showLastSelectedRoom: Boolean = true
) : MvRxState {

var showLastSelectedRoom: Boolean = true
var showLastSelectedRoom: Boolean = _showLastSelectedRoom
private set
get() {
if (field) {
field = false
if (_showLastSelectedRoom) {
_showLastSelectedRoom = false
return true
}
return false

View File

@ -15,7 +15,7 @@ class RoomSummaryController(private val context: Context,
RoomSummaryItem(
title = it.displayName,
avatarDrawable = roomSummaryViewHelper.avatarDrawable(context),
isSelected = it == selected,
isSelected = it.roomId == selected?.roomId,
listener = { callback?.onRoomSelected(it) }
)
.id(it.roomId)